simple Question about movement

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
Quote this message in a reply
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
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
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!
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.02
Post: #4
thanks, that works :-)
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  glutWarpPointer lag and fps movement Ropeburn 3 6,787 Jan 18, 2011 09:47 PM
Last Post: OneSadCookie
  AI/Movement wonza 6 4,015 Nov 26, 2008 10:23 AM
Last Post: wonza
  simple question (private) imaumac 9 3,852 Oct 21, 2008 09:37 PM
Last Post: imaumac
  Really simple #pragma question WhatMeWorry 9 4,141 Dec 13, 2006 10:15 PM
Last Post: Nick
  Simple CarbonEvent Question Abyssal 3 3,275 Jan 1, 2006 09:53 PM
Last Post: radiance