Apprentice
Posts: 9
Joined: 2010.02
Post: #1
hi,
i'am fail on a simple question (shame on me)

i have an object with a position of
0.0, 7.49, 1.8
i like to move this object over a time (2 seconds) to the new position
0.0, 48.0, 71.0

first i get the direction-vector an normalize this

my animate-function looks like this
Code:
```-(float)update :(float)timeElapsed { move the object with the normalized vector but how fast ??? }```

anyone can helps me ??
thanks
Member
Posts: 749
Joined: 2003.01
Post: #2
On the y axis you want to travel 48-7.49 in 2 seconds, so the speed on the y axis is (48-7.49)/2.

So to update the y position:

y+=(48-7.49)/2* timeElapsed

Same for x and z.

You can also do it with the normalized vector but you end up doing more calculations than you need

Â©hâ‚¬ck Ã¸ut Âµy stuÆ’Æ’ Ã¥t ragdollsoft.com
Sage
Posts: 1,403
Joined: 2005.07
Post: #3
You would like to move from A to B in t where t ranged from 0 to 2.

let u = t/2, so now u ranged from 0 to 1.

P(t) will be a function which gives you the position at time t,

You start at A, and away from A toward B, so:

P(t) = A + (B-A)*u
P(t) = A + (B-A)*(t/2)

So for example,

P(t).x = A.x + (B.x - A.x)*(t/2)

Sir, e^iÏ€ + 1 = 0, hence God exists; reply!
Apprentice
Posts: 9
Joined: 2010.02
Post: #4
thanks, that works :-)