public void Transform(Vector3d scale, Vector3d transform) { Vector3d dim = Dimension; Vector3d center = Center; center = center + transform; dim = Vector3d.ComponentMultiply(scale, dim); Min = center - dim * (double)0.5; Max = center + dim * (double)0.5; }
/// <summary> /// Obtains barycentric coordinate relative to this triangle. /// </summary> /// <param name="input">The vector that lies in triangle plane.</param> /// <returns></returns> public Vector2d GetBarycentric(Vector3d input) { //#ifdef 3D // We need positive components of normal, only magnitude relavant. Vector3d normal = this.Normal; normal = Vector3d.ComponentMultiply(normal, normal); if (normal.X > normal.Y) { if (normal.X > normal.Y) { // We project to x axis, all xs are the same. return(LinearSolver.SolveSystem(B.Y - A.Y, C.Y - A.Y, B.Z - A.Z, C.Z - A.Z, input.Y - A.Y, input.Z - A.Z)); } else { // We project to z axis, all zs are the same. return(LinearSolver.SolveSystem(B.X - A.X, C.X - A.X, B.Y - A.Y, C.Y - A.Y, input.X - A.X, input.Y - A.Y)); } } else { if (normal.Y > normal.Z) { // We project to y axis, all ys are the same. return(LinearSolver.SolveSystem(B.X - A.X, C.X - A.X, B.Z - A.Z, C.Z - A.Z, input.X - A.X, input.Z - A.Z)); } else { // We project to z axis, all zs are the same. return(LinearSolver.SolveSystem(B.X - A.X, C.X - A.X, B.Y - A.Y, C.Y - A.X, input.X - A.X, input.Y - A.Y)); } } //#endif }