Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Charles B

Poll - plane equation convention.

This topic is 5440 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

I recently changed my math code base about it due to SIMD optimizations. So I just wondered : Question what convention are you using ? (1) Plane.N * P + Plane.d; // (* P.w), * being the dot prod or (2) Plane.N * P - Plane.d In other words, for you, does the signed distance d (projected on the normal axis) mean : Plane to Origin (1) or Origin to plane (2)

Share this post

Link to post
Share on other sites
Signed distance to means from the normal. I use an intersect ray plane to find the distance, and it works like this:

d = - PlaneNormal dot PlaneOrigin
numerator = PlaneNormal dot RayOrigin + d
denominattor = PlaneNormal dot RayVector

if denominator == 0, normal is orthogonal to vector so we can't intersect.

distance = -(numer / denom)

Otherwise the signed distance from a point is basically shooting a ray from the point along the normal of the plane. It looks like or similar to this.

distance=Point dot PlaneNormal+(PlaneNormal.x*PlaneOrigin.x+PlaneNormal.y*PlaneOrigin.y+PlaneNormal.z*PlaneOrigin.z);


It doesn't matter, cause the signed distance from a plane normal to the plane will always be 1.

As far as a signed distance from a point, I say it like this..


[edited by - RhoneRanger on November 28, 2003 12:17:11 AM]

Share this post

Link to post
Share on other sites
I use the one where you subtract, it makes the most sense because it is the distance the plane is from the origin, in the direction of the plane normal. all of the quake engines use it, and this is a retarded poll

Share this post

Link to post
Share on other sites
z80 : Isn't the form Ax + By + Cz + D = N . P + D used pretty much anywhere?
Yep except in the non retarded community (ROFL).

Rhone :

You should clear your mind about PLANE EQUATIONS (Google search). I never mentionned ray/plane intersections in this thread, only planes (equations).

Mathematically, in 3D linear algebra a plane is an hyperplane. It's the orthogonal (thus supplementary) sub-space (2D) of a vector (1D). In affine math you just add a translation T which is condensed T*N = our d in question. But here I am not founding my judgement on math conventions but efficiency.

Else you are right, the convention won't change the result (of course) BUT IT MAY CHANGE CODE SPEED (SIMD). I thought my post was implictely clear about it.

If you knew me a bit more I never loose time here writing non-sense. Just because (2) is the standard used in the Quake engines (and I also used it independently well before Quake1) does not mean it's the right choice. The + choice (1) makes it possible to use less SIMD instructions. Quake3 does not use 3DNow or SSE optimizations, that's why this game is slow on old PCs. So it's not the best example.

"and this is a retarded poll"
ROFL. Thx I have 24 years of game programming experience, started at the age of 10, got trigonometry and linear algebra at the same time. I you have something to learn about 3D math, boy ask me.Thx for answering anyway.

Question :are you also one of those who believe one can't beat VisualC++ with hand written code or even code tweakings ?

Well here a clear example. The coder can choose wether he uses choice (1) or (2). The compiler can't do it for him. Eventually if you choose (1) and compile with VectorC you may produce a better .asm/.obj. I hope you learned two things today :

- keep your hurried judgements (retarded ) for yourself until you are sure.
- think out of the box.

[edited by - Charles B on November 29, 2003 7:23:04 AM]

Share this post

Link to post
Share on other sites
I type fast, I code fast and write better and faster code than what I have read in the Quake sources (1). Now if you don''t want to take profit of the valuable time spent here by some experienced 3D coders like me, don''t even waste your time reading threads. I see the level constantly degrading here because it seems the noobs become more pretentious and unpolite everyday and the real coders get tired of helping these ungrateful noobs. However I still admire Carmack specially for the implementation job he''s done concerning the BSP trees in Quake1.

Share this post

Link to post
Share on other sites
I posted more garbage but I deleted it. You're right, you're obviously god and I'm *totally* incompetent.
*too many edits, back to work*
[edited by - Shadow12345 on November 29, 2003 2:36:36 PM]

[edited by - Shadow12345 on November 29, 2003 2:37:41 PM]

[edited by - Shadow12345 on November 29, 2003 2:38:03 PM]

[edited by - Shadow12345 on November 29, 2003 2:38:26 PM]

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
I use the

- normal dot point

format in my SIMD library.

PS, not everyone uses VC++. Some of us code on PS2 etc. And yes, esp. with SIMD code you can still beat the compiler. VC++, gcc, and CW still generate redundant loads and stores.

Share this post

Link to post
Share on other sites
"you''re obviously god"

No I am not since God is unique and I mentionned experienced coders (plural). Anyway if writting better code samples (1) than ID makes one God of someone then I believe you don''t believe much. To be one of them I suppose this requires some curiousity and open mindedness, that is for instance not try to bash threads when you are not able to imagine the initial intentions about it.

You could be interested in the fact that I am writing the fastest asm/C/C++ multiplatform math lib ever produced. Dots prods in less than 2 cycles, etc ... that is as good as hand written asm ... in portable C/C+. And making such a piece of software requires to ask a well chosen set of apparently innocent questions ... I could explain 30 pages about it but you would be quickly lost. So keep on coding ... but don''t be too blind else IT''S actually wasting time. While you''ll be struggling to reach 30FPS my first debug version for the same soft will be 500FPS.

(1) I don''t talk in the void, back to planes :

Quake1 code :

if( pPlane->N.x > 0 )
dist += pPlane.N.x*pAABox->xmin;

My code :
sx = signbit(pPlane.x);
sy = ...
d = AABox[0][sx] * pPlane.N.x + AABox[0][sy] * pPlane.N.y + ....

Means box/plane is nearly as fast as a plane equation. The code in the tutorial at GameDev is 8 times slower ...

Share this post

Link to post
Share on other sites

  • 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!