Math problem, calculate slope of triangle.

I’working at landscape engine, my problem is calculate vector slope of triangle.

Landscape is compound of lot simple triangle, axis y is height.

I’know position ( x,y,z ) of my camera position, and know coordinate of
three vertex ( x,y,z ) of triangle which collide with my camera.

Right now can calculate vector slope direction??

Best Regards,

P.s. I’must simulate camera slide on slope.

P.s.s. Excuse me for bad english.

Three steps:

  1. Generate the plane from the 3 vertices. You can easily find the code somewhere on google.

  2. The equation of a plane is made from 4 components. The last one is the distance from the origin to the plane. Luckily, the three first ones are the coefficients of a normal of that plane. Get that vector. Normalize it.

  3. Make a dot product between this vector and the vertical axis (0, 1, 0). This will give you the cosinus of the angle of the slope, which is what you’re seeking…

Hope that helps…


[This message has been edited by Ysaneya (edited 10-23-2002).]