Forgot specific equasion...

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

Recommended Posts

So I found an equasion [semi]recently that compares a line (2 points) to a point and gives an output of a positive or negitive floating point value (the distance from the line?) depending on what side of the line its on. I believe its used in BSP. I was going to use it for Collision detection comparing the current and previous values from the equation to see if the point passed the lines plane, and then test to see if it actually went THROUGH the line. I think I remimbered how I can find this equasion by mentioning BSP, but all help is appreciated!

Share on other sites
If A and B are on the line, and P is the point, then you can test whether

P dot ort(B-A)

is positive or negative. dot is the dot product of vectors. ort(x,y) = (-y,x).

Share on other sites
can someone explain what he just said? because it seems like pseudo-code... and I'd really rather have an equation.

Share on other sites
Quote:
 Original post by Anonymous Postercan someone explain what he just said? because it seems like pseudo-code... and I'd really rather have an equation.

ToohrVyk gave an equation. Are you familiar with linear algebra, namely vectors?

Share on other sites
Yes, I am. So does "P dot ort(A-B)" mean "P * dot(ort(A-B))" ?

Share on other sites
Quote:
 Original post by Christopher HarrisYes, I am. So does "P dot ort(A-B)" mean "P * dot(ort(A-B))" ?

Then you're familiar with the dot product (a.k.a. scalar product, inner product), right?

http://mathworld.wolfram.com/DotProduct.html

Share on other sites
Quote:
 Original post by Christopher HarrisSo I found an equasion [semi]recently that compares a line (2 points) to a point and gives an output of a positive or negitive floating point value (the distance from the line?) depending on what side of the line its on. I believe its used in BSP. I was going to use it for Collision detection comparing the current and previous values from the equation to see if the point passed the lines plane, and then test to see if it actually went THROUGH the line.

   Public Function PointPlaneLocality(ByVal Point As Vector3, ByVal PlaneCenter As Vector3, ByVal PlaneNormal As Vector3) As Enum_PointPlaneLocality        Point.Subtract(PlaneCenter)        Dim dotPointPlane As Single = Vector3.Dot(Point, Plane)        Select Case dotPointPlane            Case Is > 0.01                Return Back            Case Is < -0.01                Return Front            Case Else                Return Coplanar        End Select    End Function

If the point is infront of the plane, it returns front, if it is behind, it returns back and if it is on the plane, it return coplanar.

To get the plane center and normal of 2 points, ptA and ptB, (ptA+ptB)/2 is the plane's origin (but you can just use ptA or ptB as they are both on the plane) and the plane's normal is a right angle to the line created by joining ptA and ptB.

1. 1
Rutin
28
2. 2
3. 3
4. 4
5. 5

• 13
• 11
• 10
• 13
• 20
• Who's Online (See full list)

There are no registered users currently online

×