public void SetPosition(Line2D line, Plane plane) { Line3D line3d = new Line3D(new Vector3D(line.v1, plane.GetZ(line.v1)), new Vector3D(line.v2, plane.GetZ(line.v2))); // This vector is perpendicular to the line, with a 90° angle between it and the plane normal Vector3D perpendicularvector = Vector3D.CrossProduct(line3d.GetDelta().GetNormal(), plane.Normal) * (-1); // This vector is on the plane, with a 90° angle to the perpendicular vector (so effectively // it's on the line, but in 3D Vector3D linevector = Vector3D.CrossProduct(plane.Normal, perpendicularvector) * (-1); Matrix m = Matrix.Null; m.M11 = linevector.x; m.M12 = linevector.y; m.M13 = linevector.z; m.M21 = perpendicularvector.x; m.M22 = perpendicularvector.y; m.M23 = perpendicularvector.z; m.M31 = plane.Normal.x; m.M32 = plane.Normal.y; m.M33 = plane.Normal.z; m.M44 = 1.0f; // The matrix is at the 0,0 origin, so move it to the start vertex of the line Vector3D tp = new Vector3D(line.v1, plane.GetZ(line.v1)); position = Matrix.Multiply(m, Matrix.Translation(RenderDevice.V3(tp))); }
/// <summary> /// This sets the position to use for the thing geometry. /// </summary> public void SetPosition(Vector3D pos) { position_v3 = RenderDevice.V3(pos); //mxd position = Matrix.Translation(position_v3); updategeo = true; updatecage = true; //mxd //mxd. update bounding box? if (lightType != null && lightRadius > thing.Size) { UpdateBoundingBox(lightRadius, lightRadius * 2); } }