math - Plane.Transform in XNA 4.0 -


i noticed today plane.transform in xna 4.0 not seem give results expected.

var s = matrix.createscale(0.1f); var p = new plane(new vector3(1.0f, 0.0f, 0.0f), 1.0f); var p = plane.transform(p, s); 

i have expected plane have magnitude of 0.1f instead has distance of 1 , normal of length 10:

{normal:{x:10 y:0 z:0} d:1} 

why happen?

i can't explain why matrix passed transform method (your scale matrix) inverted before being applied plane scale went .1 10.

the 3x3 section of matrix holds scale , rotation data gets applied normal of plane why normal got scaled.

the 4th row of matrix gets applied d part of plane since scale matrix had zeros there (except m44 had 1), d part of plane remained unchanged.

scaling plane doesn't make sense overall since plane dimensionless except d part. normal should kept @ unit length intersection test purposes scaling normal doesn't make sense. , if want d part scaled, can myplane.d *= 0.1f; instead of trying transform matrix.

speculation follows:

one possible reason matrix inversion because there 2 ways think d part.

1.) distance origin plane.

2.) distance plane origin.

both have same value oppositely signed in terms of direction. ms chose think of d distance plane origin , mean direction opposite of normal direction. likely, there reason have no idea. forces matrix inversion in plane.transform() method. see graphic here: http://msdn.microsoft.com/query/dev10.query?appid=dev10idef1&l=en-us&k=k(microsoft.xna.framework.plane);k(devlang-csharp)&rd=true


Comments