Mantheren's picture

Basis for a Plane struct


I made this basic Plane struct which I use for my planes now.
It seems to work fine as I am using it, but I don't use all the functions.

I think it has most plane related functionality, but I will need someone with better math skills than me to implement the Transform and IntersectLine functions, and perhaps expand it with more functions if I missed any.

But hopefully this can serve as some basis for a Plane struct for OpenTK.


-- Edit --
Fixed a small bug where I forgot to normalize the D attribute of the Plane. Attached the fixed version.
-- Edit End --

Plane.zip2.59 KB


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Thanks for the code, it looks great. Hope you don't mind if I add it to OpenTK.Utilities? :D

Mantheren's picture

No prob, yeah add it wherever you like of course... :P

I just assumed Math because its kinda like the vector and stuff, not really drawable just a math tool (at least for me).

But as I said, do as you please with it, I'm just glad I could be of some small help. :)

Kamujin's picture

Yeah, I'd think Plane really belongs in OpenTK.Math.

Also, it looks like you used the Plane class that I posted as a basis for this.
Since, I poached it from Axiom, we should give Axiom/OGRE proper credit in the copyright section.

Mantheren's picture

Yeah I used two of your constructors and the GetDistance function in there, indeed.
The basic layout such as IEquatable and ToString functions were taken from the Vector3 class in OpenTK.
The rest I based on the DirectX equivalent of the Plane class.

So yeah credit who you want, I definitely don't need my name above it since I only really found and grabbed everything together and commented it all.

Kamujin's picture

Same here. I poached what I posted from Axiom, so I just don't want any bad karma.

the Fiddler's picture

Haha, credit where credit's due, don't worry :D

Small problem: Axiom is LGPL so can't pick code from that directly (no problem in this case, it's trivial to rewrite the code, just something to keep in mind). It's a shame, really - so much great free code that remains incompatible due to different interpretations of freedom.

Anyway, I'll push these patches to SVN. Of course these belong to the OpenTK.Math namespace - just the Plane struct will be contained in the OpenTK.Utilities.dll, instead of OpenTK.dll.