/// <summary> /// Computes from a <see cref="V3d"/> point (origin) and /// a <see cref="V3d"/> normal the transformation matrix /// and its inverse. /// </summary> /// <param name="origin">The point which will become the new origin.</param> /// <param name="normal">The normal vector of the new ground plane.</param> /// <param name="local2global">A <see cref="M44d"/>The trafo from local to global system.</param> /// <param name="global2local">A <see cref="M44d"/>The trafofrom global to local system.</param> public static void NormalFrame(V3d origin, V3d normal, out M44d local2global, out M44d global2local ) { V3d min; double x = Fun.Abs(normal.X); double y = Fun.Abs(normal.Y); double z = Fun.Abs(normal.Z); if (x < y) { if (x < z) { min = V3d.XAxis; } else { min = V3d.ZAxis; } } else { if (y < z) { min = V3d.YAxis; } else { min = V3d.ZAxis; } } V3d xVec = Vec.Cross(normal, min); xVec.Normalize(); // this is now guaranteed to be normal to the input normal V3d yVec = Vec.Cross(normal, xVec); yVec.Normalize(); V3d zVec = normal; zVec.Normalize(); local2global = new M44d(xVec.X, yVec.X, zVec.X, origin.X, xVec.Y, yVec.Y, zVec.Y, origin.Y, xVec.Z, yVec.Z, zVec.Z, origin.Z, 0, 0, 0, 1); M44d mat = new M44d(xVec.X, xVec.Y, xVec.Z, 0, yVec.X, yVec.Y, yVec.Z, 0, zVec.X, zVec.Y, zVec.Z, 0, 0, 0, 0, 1); var shift = M44d.Translation(-origin); global2local = mat * shift; }
public void Normalize() => Normal.Normalize();
public void Normalize() { Normal.Normalize(); }