public static Point3D operator + (Point3D p1, Point3D p2) { Point3D p3 =new Point3D(0,0,0); p3._x = p1._x + p2._x; p3._y = p1._y + p2._y; p3._z = p1._z + p2._z; return p3; }
public Point3D Equals (Point3D p) { if (this != p) { _x = p._x; _y = p._y; _z = p._z; } else { //cout << "Error: copying point into itself!" << endl; } return (this); }
public LineSeg3D Subtract (LineSeg3D line, Point3D point) { LineSeg3D l = new LineSeg3D(); l.Equals(line); l -= point; return l; }
public LineSeg3D() { // Nothing much to create... _sp = new Point3D(0,0,0); _ep = new Point3D(0,0,0); }
public static Point3D operator * (MatrixFixed M, Point3D p1) { Point3D p3 = new Point3D(0,0,0); p3._x = M[0,0]*p1._x + M[0,1]*p1._y + M[0,2]*p1._z; p3._y = M[1,0]*p1._x + M[1,1]*p1._y + M[1,2]*p1._z; p3._z = M[2,0]*p1._x + M[2,1]*p1._y + M[2,2]*p1._z; return p3; }
public LineSeg3D Add (LineSeg3D line, Point3D point) { LineSeg3D l = new LineSeg3D(); l.Equals(line); l += point; return l; }
public void SetEndPoint(Point3D p) { _ep = p; }
public Quaternion(Point3D axis) { Set(axis, 0); }
public LineSeg3D Equals (LineSeg3D ls) { if (this != ls) { _sp = ls._sp; _ep = ls._ep; } else { Debug.WriteLine("Error: copying LineSeg3D into itself!"); } return this; }
public static Point3D VectorProduct(Point3D p1, Point3D p2) { return(new Point3D(p1._y*p2._z - p1._z*p2._y, p1._z*p2._x - p1._x*p2._z, p1._x*p2._y - p1._y*p2._x)); }
public Vector3D(Point3D p) : base(p) { // move along, nothing to see... }
public Point3D(Point3D p) { this.Equals(p); }
public float GetDistance(Point3D testpoint) { return (float)Math.Sqrt((testpoint._x - _x) * (testpoint._x - _x) + (testpoint._y - _y)*(testpoint._y - _y) + (testpoint._z - _z)*(testpoint._z - _z)); }
public float ScalarTripleProduct(Point3D p1, Point3D p2, Point3D p3) { float result=0; result += p1._x * (p2._y*p3._z - p3._y*p2._z); result -= p2._x * (p1._y*p3._z - p3._y*p1._z); result += p3._x * (p1._y*p2._z - p2._y*p1._z); return(result); }
public float ScalarProduct(Point3D p1, Point3D p2) { return(p1._x * p2._x + p1._y * p2._y + p1._z * p2._z); }
public LineSeg3D(float x0, float y0, float z0, float x1, float y1, float z1) { // Nothing much to create... _sp = new Point3D(x0,y0,z0); _ep = new Point3D(x1,y1,z1); }
public void SetEndPoints(Point3D p0, Point3D p1) { _sp = p0; _ep = p1; }
public LineSeg3D(Point3D p0, Point3D p1) { // Nothing much to create... _sp = p0; _ep = p1; }
public static Point3D operator / (Point3D p1, float a) { Point3D p3 = new Point3D(0,0,0); p3._x = p1._x / a; p3._y = p1._y / a; p3._z = p1._z / a; return p3; }
public void GetEndPoints(Point3D p0, Point3D p1) { p0 = _sp; p1 = _ep; }
public bool EqualTo (Point3D p) { return ((_x == p._x) && (_y == p._y) && (_z == p._z)); }
public void SetStartPoint(Point3D p) { _sp = p; }
public bool NotEqualTo (Point3D p) { return ((_x != p._x) || (_y != p._y) || (_z != p._z)); }
/// <summary> /// /// </summary> /// <param name="axis">the axis (doesn't need to be a unit vector) around which to rotate</param> /// <param name="angle">the rotation angle in radians</param> public void Set(Point3D axis, float angle) { if (Math.Abs(angle) < 1e-8) { _x = 0.0f; _y = 0.0f; _z = 0.0f; _r = 1.0f; } else { float a = angle / 2.0f; // half angle float s = (float)Math.Sin(a); float c = (float)Math.Cos(a); // Make sure the axis is a unit vector float n = 1.0f / axis.Norm(); _x = s * axis.GetX() * n; // half angle multiplied with axis _y = s * axis.GetY() * n; // half angle multiplied with axis _z = s * axis.GetZ() * n; // half angle multiplied with axis _r = c; // real part is cosine of half angle } }
public static Point3D operator - (Point3D p) { Point3D p2 = new Point3D(-p._x,-p._y,-p._z); return(p2); }
public Quaternion(Point3D axis, float angle) { Set(axis, angle); }
public static Point3D operator * (float a, Point3D p1) { Point3D p3 = new Point3D(0,0,0); p3._x = a*p1._x; p3._y = a*p1._y; p3._z = a*p1._z; return p3; }