Jump to content
  • Advertisement
Sign in to follow this  
Christopher Harris

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.

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

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 this post


Link to post
Share on other sites
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).

Share this post


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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
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.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!