drawing a plane as a big triangle

Started by
4 comments, last by Hybrid666 20 years, 9 months ago
hi, if i have my 4 values in a plane class (abcd) ... how can i convert thm to 3 points that can be drawn in opengl as a big triangle? i know its not a proper plane, its only a triangle, but it''s for debugging and would be very useful, but unfortunatly my maths aint wot it shud b cheers in advance, hybrid
Advertisement
I'm unsure why you'd want this, but I'll give it a shot...


if you know abcd, you also have to know their order...

so
a------b|      |d------c 


then, we'll make a triangle, like this
       2      /|     / |    /  |   a---b  /|   | / |   |      ^  1--d---c      |Y(positive               -> Xpositive

So we need to find the placement of 1 & 2.

Here's the simplest way I can do it...

find the length of d-c & c-b. Store which ever one is larger. so

Larger = max(length(d-c) & length(c-b)

1 = (c.x-larger*2, c.y)
2 = (c.x, c.y+larger*2)

Done, I think...

This algorthm will produce a triangle that contains your plane.










[edited by - dede on June 16, 2003 11:54:29 PM]
~~~~~Screaming Statue Software. | OpenGL FontLibWhy does Data talk to the computer? Surely he's Wi-Fi enabled... - phaseburn
Don''t planes extend infinitely, while triangles have set boundaries? And aren''t planes defined by three points (i.e. a triangle)?



-~-The Cow of Darkness-~-

If you see the image I am online

Check out PGNet.tk
-~-The Cow of Darkness-~-
I think what he means is that (a,b,c,d) are the values defining the plane equation for his plane.

In that case, drawing your triangle to represent your plane isn't too hard, but it might not look right due to a lack of tesselation.

First you have to get the 3 points that will allow you to draw your triangle. I'd suggest putting really high numbers into the plane equation for x and y, and solving for z:

point 1: (-10000,10000,z)
a*(-10000) + b*(10000) + c*(z) = d

Since you already know a,b,c, and d, you can solve for z for your first point. You can input other numbers in place of x and y to get 2 more points for your triangle. If it looks bad, try making the numbers smaller.

I hope that helped.

[edited by - halibut on June 17, 2003 3:32:36 AM]
cheers for the help, yeah a, b, c and d are the values of my plane equation, and i just want to draw a big polygon on the screeen so i can get an idea of where the plane is running, so i can debug my app better im not on my own pc at the mo so cant try out wot u guys have suggested yet, but thanks for the help, hopefully i''ll b able to sort it

cheers,
hybrid
that method will work with some planes, but could give very odd results in some cases, and in a minority of cases will be unsolvable (a plane running along the x or y axis?)

was thinking of some method that would take into account d and the normal(a,b,c) to produce points n distance away from d along the plane in a given direction. that way, a plane could be drawn in a much cleaner fashion. However, my maths aint up to much am learning tho!!

any ideas?
cheers,
hybrid

This topic is closed to new replies.

Advertisement