## Vector on slope

Member
Posts: 196
Joined: 2002.04
Post: #1
I have a vector like 1.0, 0.0, 0.0 . I want to find a new vector that follows the slope of a plane that is not parallel to the old vector. How do I change the vector to the angle of the slope? Also how can I dampen or increase the vector's speed at different angles?
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
say you have this plane
ax + by + cz = d
you know the normal of the plane (vector perpendicular to it) is (a, b, c), so to find a vector that lies on the plane pick any vector not equal to (a, b, c) and find the cross product of it and the plane's normal.

A vector doesn't have speed, but you could possibly increase the magnitude, i.e. (a, b, c) -> (k*a, k*b, k*c) would make it k times 'faster'.

Sir, e^iÏ€ + 1 = 0, hence God exists; reply!
Member
Posts: 196
Joined: 2002.04
Post: #3
Ok I can't get anything to work now. I'm using the Ax + By + Cz + D = S to find my distance to the plane (I found the formula here http://astronomy.swin.edu.au/~pbourke/ge.../planeeq/). The only problem is that the collision plane is in a different area than the actual plane that I'm drawing. Why is there a shift?
Here's my code:
http://www.solarfusionsoftware.com/devel...lision.zip
To move the point into the plane just use the w,s,a,and d keys and you can rotate everything with the t,g,f,h keys

Update:
I realized that it looked like the plane was being shifted in the opposite direction so I used this formula: Ax + By + Cz -D = S and it worked. Now I'm wondering why is Paul's formula wrong? I still can't get point to follow the slope. Instead it flys off in a different direction. Can you add it to my collision code so I can see what you're talking about? I want the point to follow the slope like this mario game: http://www.gotoandplay.it/_articles/2003...nd_run.php .