Preferred Representation of a 3D-Plane in C/C++ -


what preferred way of representing fixed-dimensional plane (struct) in 3d-graphics when c/c++ preferred language.

should we

  1. store normalized plane normal vector , origo-distance separate entities or should we
  2. express them in non-normalized vector?

first alternative requires 1 float/double other hand more efficient in algorithms operate on normal because precalculated. first alternative more numerically stable if vary normal , offset separately.

sadly, c++ not best language work planes. can @ first think using 4 floating point values choice fits in simd register in sse , vmx. may have class single 128bits member, first 3 values represent plane normal , last distance ( juste homogenous coordinate, plane not needs normalized normal if care sign of distance test ).

but when works planes categorize points, sphere, , other volumes, implementing single plane point distance function result sub-optimal algorithm because of time, know test lot of points against small number of planes. there room optimization !

the problem here has name, in fact, not problem, way may represent information. it's array of structures versus structure of arrays ( aos vs soa ).

a common exercice in 3d engine bounding volume frustum culling ! usual frustum made of 6 planes, right representation not frustum class std::array<plane,6> member, likely, 8 simd registers layout : { p0x, p1x, p2x, p3x }, { p4x, p5x, freeplane1x, freeplane2x }, ... , on y, z , d. not c++, better simd programing.

it may useful prefer soa reprensation points too.

conclusion : best representation depends on algorithm , kind of data set go thought planes.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -