/// <summary> /// Defines the view matrix with an eye position, a look at point and an up vector. /// This method is equivalent to the OpenGL function gluLookAt. /// If Up is a zero vector a default up vector is calculated with a default /// look-right vector (VZ) that lies in the x-z plane. /// </summary> /// <param name="Eye">Eye Vector to the position of the eye (view point)</param> /// <param name="At">At Vector to the target point</param> /// <param name="Up">Up Vector that points from the viewpoint upwards.</param> public void LookAt(SLVec3f Eye, SLVec3f At, SLVec3f Up) { SLVec3f VX, VY, VZ, VT, ZERO; //SLMat3<T> xz(0.0, 0.0, 1.0, // matrix that transforms YZ into a // 0.0, 0.0, 0.0, // vector that is perpendicular to YZ and // -1.0, 0.0, 0.0); // lies in the x-z plane VZ = Eye - At; VZ.Normalize(); VX = new SLVec3f(); ZERO = new SLVec3f(); if (Up == ZERO) { VX.x = VZ.z; VX.y = 0; VX.z = -1 * VZ.x; } else { VX = Up.Cross(VZ); } VY = SLVec3f.CrossProduct(VZ, VX); VX.Normalize(); VY.Normalize(); VZ.Normalize(); VT = -Eye; Set(VX.x, VX.y, VX.z, SLVec3f.DotProduct(VX, VT), VY.x, VY.y, VY.z, SLVec3f.DotProduct(VY, VT), VZ.x, VZ.y, VZ.z, SLVec3f.DotProduct(VZ, VT), 0.0f, 0.0f, 0.0f, 1.0f); }
public void SetZNormal() { VX = myEndXAxis - myOrigin; if (IsSameDbl(VX.Length, 0)) { return; } VX.Normalise(); VY = myEndYAxis - myOrigin; if (IsSameDbl(VY.Length, 0)) { return; } VY.Normalise(); VZ = VX.Cross(VY); if (IsSameDbl(VZ.Length, 0)) { return; } VZ.Normalise(); VY = VZ.Cross(VX); if (IsSameDbl(VY.Length, 0)) { return; } VY.Normalise(); }
new public string ToXML() { string s = xmlStartTag; s += "<VX>" + VX.ToString(); s += "</VX><VY>" + VY.ToString(); s += "</VY><VZ>" + VZ.ToString() + "</VZ>"; s += xmlEndTag; return(s); }
public override string ToString() { string stroka = ""; stroka = n.ToString() + " "; foreach (double M in m) { stroka += M.ToString() + " "; } foreach (double X in x) { stroka += X.ToString() + " "; } foreach (double Y in y) { stroka += Y.ToString() + " "; } foreach (double Z in z) { stroka += Z.ToString() + " "; } foreach (double VX in vx) { stroka += VX.ToString() + " "; } foreach (double VY in vy) { stroka += VY.ToString() + " "; } foreach (double VZ in vz) { stroka += VZ.ToString() + " "; } stroka = stroka + "\n"; return(String.Format("{0}", stroka)); }
public void Load(System.IO.StreamReader sr) { clsPoint3d p1; //var version = myPGLoadedVersion.Split('.'); //var nLoadedVersionMajor = version.Count() >= 1 ? Convert.ToInt32(version[0]) : 0; //var nLoadedVersionMinor = version.Count() >= 2 ? Convert.ToInt32(version[1]) : 0; while (sr.EndOfStream == false) { var myLine = sr.ReadLine(); if (myLine == "END_MARKER_POINT_SETTINGS") { break; } if (myLine.IndexOf(",") > -1) { var mySplit = myLine.Split(','); if (mySplit.GetUpperBound(0) == 1) { if (mySplit[0] == "MarkerID") { myMarkerID = Convert.ToInt32(mySplit[1]); } if (mySplit[0] == "SeenFromMarkerID") { mySeenFromMarkerID = Convert.ToInt32(mySplit[1]); } if (mySplit[0] == "SeenFromMarkerIDs") { mySeenFromMarkerIDs.Add(Convert.ToInt32(mySplit[1])); } if (mySplit[0] == "ActualMarkerID") { myActualMarkerID = Convert.ToInt32(mySplit[1]); } if (mySplit[0] == "VerticalVectorX") { if (myVerticalVect == null) { myVerticalVect = new clsPoint3d(); } myVerticalVect.X = Convert.ToDouble(mySplit[1]); } if (mySplit[0] == "VerticalVectorY") { if (myVerticalVect == null) { myVerticalVect = new clsPoint3d(); } myVerticalVect.Y = Convert.ToDouble(mySplit[1]); } if (mySplit[0] == "VerticalVectorZ") { if (myVerticalVect == null) { myVerticalVect = new clsPoint3d(); } myVerticalVect.Z = Convert.ToDouble(mySplit[1]); } if (mySplit[0] == "BulkheadHeight") { BulkheadHeight = Convert.ToDouble(mySplit[1]); } if (mySplit[0] == "Confirmed") { _confirmed = (mySplit[1] == "1"); } } } } if (mySeenFromMarkerIDs.Contains(mySeenFromMarkerID) == false) { mySeenFromMarkerIDs.Add(mySeenFromMarkerID); } myOrigin.Load(sr); myEndXAxis.Load(sr); myEndYAxis.Load(sr); myPoint.Load(sr); VX.Load(sr); VY.Load(sr); VZ.Load(sr); var n = Convert.ToInt32(sr.ReadLine()); for (var i = 1; i <= n; i++) { p1 = new clsPoint3d(); p1.Load(sr); myCameraPoints.Add(p1); } n = Convert.ToInt32(sr.ReadLine()); for (var i = 1; i <= n; i++) { p1 = new clsPoint3d(); p1.Load(sr); mySeenFromCameraPoints.Add(p1); } n = Convert.ToInt32(sr.ReadLine()); for (var i = 1; i <= n; i++) { p1 = new clsPoint3d(); p1.Load(sr); myPts1.Add(p1); } n = Convert.ToInt32(sr.ReadLine()); for (var i = 1; i <= n; i++) { p1 = new clsPoint3d(); p1.Load(sr); myPts2.Add(p1); } n = Convert.ToInt32(sr.ReadLine()); for (var i = 1; i <= n; i++) { p1 = new clsPoint3d(); p1.Load(sr); myPts3.Add(p1); } n = Convert.ToInt32(sr.ReadLine()); for (var i = 1; i <= n; i++) { p1 = new clsPoint3d(); p1.Load(sr); GyroData.Add(p1); } n = Convert.ToInt32(sr.ReadLine()); for (var i = 1; i <= n; i++) { p1 = new clsPoint3d(); p1.Load(sr); LastGyroData.Add(p1); } n = Convert.ToInt32(sr.ReadLine()); for (var i = 1; i <= n; i++) { p1 = new clsPoint3d(); p1.Load(sr); AccelData.Add(p1); } n = Convert.ToInt32(sr.ReadLine()); for (var i = 1; i <= n; i++) { p1 = new clsPoint3d(); p1.Load(sr); LastAccelData.Add(p1); } n = Convert.ToInt32(sr.ReadLine()); for (var i = 1; i <= n; i++) { var myHistoricPoint = new clsMarkerPoint(); myHistoricPoint.Load(sr); myHistory.Add(myHistoricPoint); } }
public void Save(System.IO.StreamWriter sw) { sw.WriteLine("MARKER_POINT_SETTINGS"); sw.WriteLine("MarkerID," + myMarkerID.ToString()); sw.WriteLine("SeenFromMarkerID," + mySeenFromMarkerID.ToString()); sw.WriteLine("ActualMarkerID," + myActualMarkerID.ToString()); if (myVerticalVect != null) { sw.WriteLine("VerticalVectorX," + myVerticalVect.X.ToString()); sw.WriteLine("VerticalVectorY," + myVerticalVect.Y.ToString()); sw.WriteLine("VerticalVectorZ," + myVerticalVect.Z.ToString()); } sw.WriteLine("BulkheadHeight," + BulkheadHeight.ToString()); foreach (int myID in mySeenFromMarkerIDs) { sw.WriteLine("SeenFromMarkerIDs," + myID.ToString()); } sw.WriteLine("Confirmed," + (_confirmed ? "1" : "0")); sw.WriteLine("END_MARKER_POINT_SETTINGS"); myOrigin.Save(sw); myEndXAxis.Save(sw); myEndYAxis.Save(sw); myPoint.Save(sw); VX.Save(sw); VY.Save(sw); VZ.Save(sw); sw.WriteLine(myCameraPoints.Count); foreach (clsPoint3d p1 in myCameraPoints) { p1.Save(sw); } sw.WriteLine(mySeenFromCameraPoints.Count); foreach (clsPoint3d p1 in mySeenFromCameraPoints) { p1.Save(sw); } sw.WriteLine(myPts1.Count); foreach (clsPoint3d p1 in myPts1) { p1.Save(sw); } sw.WriteLine(myPts2.Count); foreach (clsPoint3d p1 in myPts2) { p1.Save(sw); } sw.WriteLine(myPts3.Count); foreach (clsPoint3d p1 in myPts3) { p1.Save(sw); } sw.WriteLine(GyroData.Count); for (int i = 0; i < GyroData.Count; i++) { GyroData[i].Save(sw); } sw.WriteLine(LastGyroData.Count); for (int i = 0; i < LastGyroData.Count; i++) { LastGyroData[i].Save(sw); } sw.WriteLine(AccelData.Count); for (int i = 0; i < AccelData.Count; i++) { AccelData[i].Save(sw); } sw.WriteLine(LastAccelData.Count); for (int i = 0; i < LastAccelData.Count; i++) { LastAccelData[i].Save(sw); } sw.WriteLine(myHistory.Count); foreach (clsMarkerPoint myHistoricPoint in myHistory) { myHistoricPoint.Save(sw); } }