Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { useEffect } from 'react'
- import { useSelector } from 'react-redux'
- import {
- selectIsModeling,
- selectObjectModelm,
- selectObjectModelR,
- } from 'selectors'
- export const useModeling = () => {
- const isModeling = useSelector(selectIsModeling)
- const m = useSelector(selectObjectModelm)
- const r = useSelector(selectObjectModelR)
- const g = 9.8
- const V0 = 0
- const t = 0.1
- const n = 0.0182
- const C = 0.4
- const S = Math.PI * r * r
- const p = 1.89
- const k1 = 6 * Math.PI * r * n
- const k2 = (C * S * p) / 2
- useEffect(() => {
- console.log('modeling')
- if (!isModeling) return
- let i = 100
- let Vi = V0
- const calculateVi = function () {
- console.log(123)
- if (!isModeling || --i === 0) return
- const CC = (m * g - k1 * Vi - k2 * Vi * Vi) / m
- const DD = Vi + t * CC
- const c = (m * g - k1 * CC - k2 * DD * DD) / m
- console.log(Vi)
- Vi = Vi + (t / 2) * (CC + c)
- calculateVi()
- }
- calculateVi()
- }, [isModeling])
- }
Add Comment
Please, Sign In to add comment