public static CoordSys NewCoordSys(CoordSys coordSys) { CoordSys newCoord = new CoordSys() { Center = coordSys.Center, Top = coordSys.Top, Side = coordSys.Side, Front = coordSys.Front }; newCoord.Side.Y = coordSys.Center.Y; newCoord.Top.X = coordSys.Center.X; CameraSpacePoint transSideN = newCoord.Center.SubtractFrom(newCoord.Side); CameraSpacePoint transFrontN = newCoord.Center.SubtractFrom(newCoord.Front); CameraSpacePoint transTopN = newCoord.Center.SubtractFrom(newCoord.Top); transFrontN = transSideN.CrossProduct(transTopN); newCoord.Top = transTopN.Add(coordSys.Center); newCoord.Side = transSideN.Add(coordSys.Center); newCoord.Front = transFrontN.Add(coordSys.Center); //newCoord.Front = newCoord.Side.CrossProduct(newCoord.Top); //newCoord.Front.X = coordSys.Center.X; //newCoord.Front.Y = coordSys.Center.Y; return(newCoord); }
public static FaceAngleEuler CalculateFaceAngle(CoordSys coordSys, bool withRelToCamera = true) { CameraSpacePoint transSide = coordSys.Center.SubtractFrom(coordSys.Side); CameraSpacePoint transFront = coordSys.Center.SubtractFrom(coordSys.Front); CameraSpacePoint transTop = coordSys.Center.SubtractFrom(coordSys.Top); CameraSpacePoint transSide2D = transSide; transSide2D.Y = 0; CameraSpacePoint transFront2D = transFront; transFront2D.X = 0; CameraSpacePoint transTop2D = transTop; transTop2D.Z = 0; transSide2D = transSide2D.Norm(); transFront2D = transFront2D.Norm(); transTop2D = transTop2D.Norm(); FaceAngleEuler angles = new FaceAngleEuler() { R = (float)(Math.Asin(transTop2D.X) * 180 / Math.PI), Y = (float)(Math.Asin(transSide2D.Z) * 180 / Math.PI), P = (float)(Math.Asin(transFront2D.Y) * 180 / Math.PI) }; return(angles); }
public void Update(IReadOnlyList <CameraSpacePoint> vertices) { this.faceFrameAttributes = faceFrameAttributes; this.Vertices = new List <CameraSpacePoint>(vertices); this.CoordSys = Utilities.CalculateCoordSystem(vertices); CoordSys newC = Utilities.NewCoordSys(CoordSys); this.FaceAngleEuler = Utilities.CalculateFaceAngle(this.CoordSys); //this.FaceAngleEuler = Utilities.CalculateFaceAngleColor(this.CoordSys, newC, mapper); //this.CoordSys = newC; }
public static FaceAngleEuler CalculateFaceAngleColor(CoordSys coordSys, CoordSys newCoord, CoordinateMapper mapper) { CameraSpacePoint transSide = coordSys.Center.SubtractFrom(coordSys.Side); CameraSpacePoint transFront = coordSys.Center.SubtractFrom(coordSys.Front); CameraSpacePoint transTop = coordSys.Center.SubtractFrom(coordSys.Top); CameraSpacePoint transSideN = newCoord.Center.SubtractFrom(newCoord.Side); CameraSpacePoint transFrontN = newCoord.Center.SubtractFrom(newCoord.Front); CameraSpacePoint transTopN = newCoord.Center.SubtractFrom(newCoord.Top); CameraSpacePoint transSide2D = transSide; transSide2D.Y = 0; CameraSpacePoint transFront2D = transFront; transFront2D.X = 0; CameraSpacePoint transTop2D = transTop; transTop2D.Z = 0; transSide2D = transSide2D.Norm(); transFront2D = transFront2D.Norm(); transTop2D = transTop2D.Norm(); CameraSpacePoint transSideN2D = transSideN; transSideN2D.Y = 0; CameraSpacePoint transFrontN2D = transFrontN; transFrontN2D.X = 0; CameraSpacePoint transTopN2D = transTopN; transTopN2D.Z = 0; transSideN2D = transSideN2D.Norm(); transFrontN2D = transFrontN2D.Norm(); transTopN2D = transTopN2D.Norm(); //FaceAngleEuler angles = new FaceAngleEuler() //{ // R = (float)(Math.Asin(transTop2D.X * transTopN2D.X) * 180 / Math.PI), // Y = (float)(Math.Asin(transSide2D.Z * transSideN2D.Z) * 180 / Math.PI), // P = (float)(Math.Asin(transFront2D.Y * transFrontN2D.Y) * 180 / Math.PI) //}; FaceAngleEuler angles = new FaceAngleEuler() { R = (float)(Math.Acos(transTop2D.DotProduct(transTopN2D)) * 180 / Math.PI), Y = (float)(Math.Acos(transSide2D.DotProduct(transSideN2D)) * 180 / Math.PI), P = (float)(Math.Acos(transFront2D.DotProduct(transFrontN2D)) * 180 / Math.PI) }; return(angles); }