Sign in to follow this  

Nevermind I trashed my code

Recommended Posts

So I'm making a quad-tree. So essentially I am flattening the Camera Frustum(to the X/Z axis), and testing to see if it holds a bunch of squares or intersects them. The faster the routine the better. If it helps at all my square is a true square(equal length and width). edit: It's recently come to my attention that a trapezoid is just one truncated triangle. Thanks IRC haha. So now I just need to figure out how to test is a square is in a triangle. [Edited by - Cakey on June 22, 2009 5:22:54 PM]

Share this post

Link to post
Share on other sites
Is it going to be significantly slow to test every single point? With a method such as:

private bool isPointInTriangle(Vector2 Point, Vector2 A, Vector2 B, Vector2 C){
float Orientation1 = Orientation(A, B, Point),
Orientation2 = Orientation(B, C, Point),
Orientation3 = Orientation(C, A, Point);
if(Orientation1 == Orientation2 && Orientation2 == Orientation3)
{return true;}
else{return false;}

private int Orientation(Vector2 Begin, Vector2 End, Vector2 Point){
//Linear determinant
float Orin = (End.X - Begin.X) * (Point.Y - Begin.Y) - (Point.X - Begin.X) * (End.Y - Begin.Y);
if (Orin > 0.0){return 1;} //Orientation to the right
else if (Orin < 0.0) {return -1;} //Orientation to the left
else{return 0;} //Orientation is middle bound

(Also I dunno if that code is right I have yet to test it)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this