Jump to content
  • Advertisement
Sign in to follow this  
TheSeb

maths in order to make collisions detections(i still have a question)

This topic is 4528 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Can you help me to understand this ? i'm not very strong in maths... plane is represented using its Vector representation as: Xn dot X = d Xn, X are vectors and d is a floating point value. Xn is its normal. X is a point on its surface. d is a float representing the distance of the plane along the normal, from the center of the coordinate system. me:is he talking about the origin ? if yes how can we be along the normal and start from the origin ? what is the variable "d" ? why do we do Xn dot X to find d ? tell me if you need more infos Essentially a plane represents a half space. So all that we need to define a plane is a 3D point and a normal from that point which is perpendicular to that plane. These two vectors form a plane, ie. if we take for the 3D point the vector (0,0,0) and for the normal (0,1,0) we essentially define a plane across x,z axes. Therefore defining a point and a normal is enough to compute the Vector representation of a plane. Using the vector equation of the plane the normal is substituted as Xn and the 3D point from which the normal originates is substituted as X. The only value that is missing is d which can easily be computed using a dot product (from the vector equation). (Note: This Vector representation is equivalent to the widely known parametric form of the plane Ax + By + Cz + D=0 just take the three x,y,z values of the normal as A,B,C and set D=-d). [Edited by - TheSeb on January 1, 2006 12:35:32 PM]

Share this post


Link to post
Share on other sites
Advertisement
Let's start with the eqn:

r.n = d

r is the position vector of any point on the plane. n is the unit normal to the plane surface, and we are coming to d in a bit.

You probably understand what the normal is, it is perpendicular to the surface of the plane. Now, if I give you any point's coordinates, you can easily see how there is 1 line through it which is perpendicular to the plane (these lines are just a family of parallel lines). The distance of the plane from the point is just the measure of the line segment between the point and the plane (along the line you just found).

d is nothing but the distance of the plane from the origin, that is if we take the origin to be our point of interest in the discussion in the preeceding paragraph, you will get the value of d.

Now I hope that's all clear [smile]. This is helpful in collision detection because if you know the equation of a plane, you can easily find the distance of any point from the plane. Say the point is a. The distance of a from the plane is:

a.n - d

The sign of this expression changes as the point a moves from one side of the plane to the other. Thus, you can do your collision detection.

Share this post


Link to post
Share on other sites
thank you very much, i have still one question :
in the tutorial after what i posted they do that :

The two equations we have so far are:

PointOnRay = Raystart + t * Raydirection
Xn dot X = d

If a ray intersects the plane at some point then there must be some point on the ray which satisfies the plane equation as follows:

Xn dot PointOnRay = d or (Xn dot Raystart) + t * (Xn dot Raydirection) = d

solving for t:

t = (d - Xn dot Raystart) / (Xn dot Raydirection)

there is what you told me : d - Xn dot Raystart but they divide by Xn dot Raydirection. Why ?

Share this post


Link to post
Share on other sites
P = S + t * D
P . N - d = 0
(S . N) + t * (D . N) - d = 0
(S . N) + t * (D . N) = d
t = (d - (S . N)) / (D . N)

Does that stil confuse you? [grin]

Share this post


Link to post
Share on other sites
Quote:
Original post by oliii
P = S + t * D
P . N - d = 0
(S . N) + t * (D . N) - d = 0
(S . N) + t * (D . N) = d
t = (d - (S . N)) / (D . N)

Does that stil confuse you? [grin]


hi hi hi !

Share this post


Link to post
Share on other sites
The distance of an arbitrary point X away from a plane is defined to be the length of the shortest straight line from any point on the plane to X. Obviously, that line has to be orthogonal to the plane, or its length could not be minimal. A vector orthogonal to the plane is its normal, lets name it nP. Let nP not only being orthogonal but also of unit length for simplicity.

To check out the length of the shortest line mentioned above, we choose any arbitrary point on the plane. Lets call that point OP the "origin" of the plane. The difference vector of the origin of the plane to X is
X - OP
Since the normal of the plane nP is chosen with unit length, the dot product
( X - OP ) dot nP
gives the length of the difference vector projected onto the normal, what in fact is the length of the shortest line.

Now, for any point X lying directly onto the plane, the distance is obviously zero. So one could express
( X - OP ) . nP = 0
Multiplying out and moving the constant term onto the right, one gets
X . nP = OP . nP
or, with the RHS term being computed to its constant scalar d
X . nP = d

Now, a ray starting at R0 and traveling along direction r by a multiple of t touched all points in space as
R(t) := R0 + t * r

So, any point on the ray R(t) that simultanously is also on the plane must fulfil the plane equation if substituting X
R(t) . nP = d
or, after replacing R(t) by its definition
R0 . nP + t * r . nP = d
The only unkown is the ray travel distance t, so isolate it
t * r . nP = d - R0 . nP
t = ( d - R0 . nP ) / ( r . nP )
So Xn dot Raydirection occurs in the fraction.

From math you know not to divide by zero, so you need to ensure that
r . nP != 0
But what if it is zero? Due to the definition of the dot product, that would mean that the ray's direction and the plane's normal are orthogonal, say, the ray's track is parallel to the plane, and hence has inifinitely many hit points (if its origin is also inside the plane) or none hit point at all.

Share this post


Link to post
Share on other sites
thanks but here, i have a problem to understand how a dot product which gives the cosine of an angle can give us the lenght like here :

Since the normal of the plane nP is chosen with unit length, the dot product
( X - OP ) dot nP
gives the length of the difference vector projected onto the normal, what in fact is the length of the shortest line

Share this post


Link to post
Share on other sites
The full flavor of dot product is
a . b := ||a|| * ||b|| * cos<a,b>
what means that the dot product is identical to the product of the length of both vectors and the cosine between them.

So, with the one vector (say b) being of unit length, so that
||b|| = 1
the dot product in our special case is
||a|| * cos<a,b>
what is the length of a projected onto b (or, in other words, the length of a in direction of b).

EDIT: So statements like "a dot product being 0 means orthogonality" (as I've self used in the post above) is correct only if both vectors are not zero; but most often this is implicitely assumed.

[Edited by - haegarr on January 1, 2006 2:25:23 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!