3 Replies Latest reply on Mar 15, 2013 3:41 AM by Minds Eye

# Vector question

Hello.

Can someone help me?

I've been trying to get my head around vector calculations but been getting a bit stuck!

I have physics with a ball that I want to roll around on a plane. Rather than rotating everything in the world about a point which would get really complicated, I figured it would be easier to simply rotate the gravity!

So I have gravity in my 3D World (using the standard Physics Xtra that comes with D11.5) and I have the gravity as a vector pointing downwards:

pPhysics.gravity = vector( 0.0, 0.0, -9.81 )

And so I want to rotate the gravity a few degrees about any x y axis.

I've been getting really really stuck on this.

Any suggestions would be most appreciated.

Trevor

• ###### 1. Re: Vector question

Anyone?

• ###### 2. Re: Vector question

Multiplying the vector by a rotated transform may provide the results you are looking for.

on test

v = vector(0, 0, -9.81)

t = transform()

t.rotate(1, 1, 0)

put v

-- rotate in X, Y directions

repeat with cnt = 1 to 10

v = t * v

put v

end repeat

-- rotate back

t.rotate(-2, -2, 0)  -- reverse rotation

repeat with cnt = 1 to 10

v = t * v

put v

end repeat

end test

• ###### 3. Re: Vector question

Perfect!

Thank you very much.

Trevor