c++ - Transforming a plane with DirectXTK / DirectXMath -


i have 3d plane defined 3 points , want transform 4x4 matrix using directxtk.

i tried 2 ways this:

  1. transform plane plane::transform() method - gives strange result.

  2. transform 3 points , create plane transformed points - works fine.

i tried transpose matrix before calling plane::transform() , got plane normal right, constant wrong (plus transposing matrix makes no sense me).

void testplanetransform() {     vector3 p1(-2.4f, -2.0f, -0.2f);     vector3 p2(p1.x, p1.y + 1, p1.z);     vector3 p3(p1.x, p1.y, p1.z + 1);      plane plane(p1, p2, p3);     matrix m = matrix::createtranslation(-4, -3, -2);      // transform plane matrix     plane result1 = plane::transform(plane, m);      // transform plane transposed matrix     plane result2 = plane::transform(plane, m.transpose());      // transform points matrix     vector3 t1 = vector3::transform(p1, m);     vector3 t2 = vector3::transform(p2, m);     vector3 t3 = vector3::transform(p3, m);      // plane transformed points     plane result3(t1, t2, t3);      result1.normalize();     result2.normalize();     result3.normalize(); } 

here results after normalization:

result1 x:-0.704918027 y:-0.590163946 z:-0.393442601 w:0.196721300  result2 x:1.00000000 y:0.000000000 z:0.000000000 w:-1.59999990  result3 x:1.00000000 y:0.000000000 z:0.000000000 w:6.40000010 

plane::transform() calls xmplanetransform part of directxmath library , documentation says "transforms plane given matrix.". guess method fine, wrong code?

since calling transform on directxtk plane seems it's not required have normalized before doing call. directxtk wiki plane::transform states this:

planes should transformed inverse transpose of matrix, pure rotations results in same matrix original.

github.com/microsoft/directxtk/wiki/plane


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -