normals to a plane

Started by
8 comments, last by JTippetts 12 years, 10 months ago
hi,
I have a 3D shape which is a right angles triangle shape. Like a bike ramp.

I have an object that moves up the ramp.

What I need to know is given an x,y,z point how do i know if this point will be inside or outside this 3D object.
I really need to know if this point is just touching the ramp.

maybe easiest to see the mathematics
Advertisement
If you have a 3D triangle made up of 3 points, V0, V1 and V2, you can find the normal, n, of the plane upon which the triangle lies by:

(V1-V0) x (V2-V0)

where x is the cross product operation. If you follow a consistent rule for winding order of all the triangles in your mesh, then all the normals for all the faces will point outside of the mesh. To test which side of a plane a given point, P, lies upon you can use the formula to find the distance between the point and a plane:

d = (n dot (P - V0)) / (| n |)

where | n | is the length of n, in this case 1 if you normalized the normal vector to unit length.

If the result of this calculation, d, is negative, the point lies "below" the plane, if the result is 0 the point lies on the plane, and if the result is positive the point lies above the plane. If the mesh is convex, you can test for a point being inside the object by testing it against all the triangles of the object, and if any result is positive, the point does not lie inside the mesh. If you know which faces a point is likely to intersect (such as your example of a point traveling up a ramp) you can just test those faces.
let me see if i have this right

i will find the suface that is on a slope for right angled triangle 3d Shape (the longest side).

now the slope is at a 45 deg angle .

4 points around this rectangle surface is
A(0,0,0)
B(200,0,0)
C(200,71,71)
D(0,71,71)

V1 vector1= B - A (200,0,0)
V2 vector2=C - A (200,71,71)

cross product vector1 X vector2

cross product x= v1.y X v2.z - v1.zX v2.y = 0X71 - 71X0= 0
cross product y= - (( v2.z X v1.x) - (v2.x X v1.z)) = - 71X200 -0= -14200
cross product z= v1.x X v2.y - v1.y X v2.x= 14200

(0,-14200,14200) is normal

is this correct?

let me see if i have this right

i will find the suface that is on a slope for right angled triangle 3d Shape (the longest side).

now the slope is at a 45 deg angle .

4 points around this rectangle surface is
A(0,0,0)
B(200,0,0)
C(200,71,71)
D(0,71,71)

V1 vector1= B - A (200,0,0)
V2 vector2=C - A (200,71,71)

cross product vector1 X vector2

cross product x= v1.y X v2.z - v1.zX v2.y = 0X71 - 71X0= 0
cross product y= - (( v2.z X v1.x) - (v2.x X v1.z)) = - 71X200 -0= -14200
cross product z= v1.x X v2.y - v1.y X v2.x= 14200

(0,-14200,14200) is normal

is this correct?


Correct. I'd also normalize the normal to save some headaches during programming.
(0,-14200,14200) is normal so normalize i get

20081 = normalize factor

(0, -.707, .707)

now since y value is negative the normal points down but i want it to point up dont I out of the surface?
If your normal is pointing the wrong way, switch the order in which you do the cross product. So, do Vector2 x Vector1 instead.

If your normal is pointing the wrong way, switch the order in which you do the cross product. So, do Vector2 x Vector1 instead.


what has happened is that I am using away3D.

z axis has positive values into the screen and negative values out of the screen.

so will switching the order in which you do the cross product solve this?
Switching the order of the cross product will switch the direction of the normal from one side of the plane to the other. You can also just multiply your vector by -1 to invert it as well. A normal is basically just a vector after all.
thanks for the help

speaking of just a vector what confuses me is the concept of vector has a direction.
It is just a 3D point and we are saying it also points to a direction.

how do we know what direction it points at because a point on x,y,z could point in any direction theoretically
A vector and a point are conceptually different, even if their representation is the same. When an (x,y,z) coordinate is referred to as a vector, it is commonly understood to point from the origin, (0,0,0).

This topic is closed to new replies.

Advertisement