Forgot specific equasion...

Started by
5 comments, last by CadeF 18 years, 3 months ago
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!
Advertisement
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).
can someone explain what he just said? because it seems like pseudo-code... and I'd really rather have an equation.
Quote:Original post by Anonymous Poster
can 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?
Yes, I am. So does "P dot ort(A-B)" mean "P * dot(ort(A-B))" ?
Quote:Original post by Christopher Harris
Yes, 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
Quote:Original post by Christopher Harris
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.


   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.

This topic is closed to new replies.

Advertisement