# Nevermind I trashed my code

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

## 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 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)

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• ### Forum Statistics

• Total Topics
631788
• Total Posts
3002356
×