public float Multiply(LineSeg3D ls1, LineSeg3D ls2) { Vector3D d1 = new Vector3D(ls1._ep - ls1._sp); Vector3D d2 = new Vector3D(ls2._ep - ls2._sp); return(d1.GetX() * d2.GetX() + d1.GetY() * d2.GetY() + d1.GetZ() * d2.GetZ()); }
public LineSeg3D Subtract(LineSeg3D line, Point3D point) { LineSeg3D l = new LineSeg3D(); l.Equals(line); l -= point; return(l); }
public LineSeg3D Add(LineSeg3D line, Point3D point) { LineSeg3D l = new LineSeg3D(); l.Equals(line); l += point; return(l); }
// Rotate a line segment. // param l the line segment to be rotated // @returns the resulting rotated line segment public LineSeg3D Rotate(LineSeg3D l) { // Simply rotate both lines Vector3D i = this.Imaginary(); Vector3D ns = new Vector3D(Vector3D.VectorProduct(i, l.StartPoint())); Vector3D ne = new Vector3D(Vector3D.VectorProduct(i, l.EndPoint())); Vector3D deltas = new Vector3D(_r * ns - (Vector3D)(Vector3D.VectorProduct(ns, i))); Vector3D deltae = new Vector3D(_r * ne - (Vector3D)(Vector3D.VectorProduct(ne, i))); LineSeg3D result = new LineSeg3D(l.StartPoint() + 2.0f * deltas, l.EndPoint() + 2.0f * deltae); return(result); }
public LineSeg3D Equals(LineSeg3D ls) { if (this != ls) { _sp = ls._sp; _ep = ls._ep; } else { Debug.WriteLine("Error: copying LineSeg3D into itself!"); } return(this); }
// Rotate a line segment. // @param l the line segment to be rotated // @returns the resulting rotated line segment public LineSeg3D Rotate(LineSeg3D l) { // Simply rotate both lines float angle = (float)Math.Sqrt(_x * _x + _y * _y + _z * _z); if (angle < 1e-8) { return(l); } float sn = (float)Math.Sin(angle); float cs = (float)Math.Cos(angle); Vector3D axis = new Vector3D(_x / angle, _y / angle, _z / angle); Vector3D ns = new Vector3D(Point3D.VectorProduct(axis, l.StartPoint())); Vector3D ne = new Vector3D(Point3D.VectorProduct(axis, l.EndPoint())); Vector3D deltas = new Vector3D(sn * ns + (cs - 1.0f) * (Point3D.VectorProduct(ns, axis))); Vector3D deltae = new Vector3D(sn * ne + (cs - 1.0f) * (Point3D.VectorProduct(ne, axis))); return(new LineSeg3D(l.StartPoint() + deltas, l.EndPoint() + deltae)); }
public float Multiply(LineSeg3D ls1, LineSeg3D ls2) { Vector3D d1 = new Vector3D(ls1._ep - ls1._sp); Vector3D d2 = new Vector3D(ls2._ep - ls2._sp); return (d1.GetX() * d2.GetX() + d1.GetY() * d2.GetY() + d1.GetZ() * d2.GetZ()); }
public bool EqualTo (LineSeg3D ls) { return ((_sp==ls._sp) && (_ep==ls._ep)); }
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 LineSeg3D Subtract (LineSeg3D line, Point3D point) { LineSeg3D l = new LineSeg3D(); l.Equals(line); l -= point; return l; }
public LineSeg3D Add (LineSeg3D line, Point3D point) { LineSeg3D l = new LineSeg3D(); l.Equals(line); l += point; return l; }
// Rotate a line segment. // param l the line segment to be rotated // @returns the resulting rotated line segment public LineSeg3D Rotate(LineSeg3D l) { // Simply rotate both lines Vector3D i = this.Imaginary(); Vector3D ns = new Vector3D(Vector3D.VectorProduct(i, l.StartPoint())); Vector3D ne = new Vector3D(Vector3D.VectorProduct(i, l.EndPoint())); Vector3D deltas = new Vector3D(_r * ns - (Vector3D)(Vector3D.VectorProduct(ns, i))); Vector3D deltae = new Vector3D(_r * ne - (Vector3D)(Vector3D.VectorProduct(ne, i))); LineSeg3D result = new LineSeg3D(l.StartPoint() + 2.0f * deltas, l.EndPoint() + 2.0f * deltae); return (result); }
public float Norm(LineSeg3D ls) { return((float)Math.Sqrt((ls._ep._x - ls._sp._x) * (ls._ep._x - ls._sp._x) + (ls._ep._y - ls._sp._y) * (ls._ep._y - ls._sp._y) + (ls._ep._z - ls._sp._z) * (ls._ep._z - ls._sp._z))); }
public float Norm2(LineSeg3D ls) { return((ls._ep._x - ls._sp._x) * (ls._ep._x - ls._sp._x) + (ls._ep._y - ls._sp._y) * (ls._ep._y - ls._sp._y) + (ls._ep._z - ls._sp._z) * (ls._ep._z - ls._sp._z)); }
public bool EqualTo(LineSeg3D ls) { return((_sp == ls._sp) && (_ep == ls._ep)); }
public float Norm2(LineSeg3D ls) { return ((ls._ep._x-ls._sp._x)*(ls._ep._x-ls._sp._x) + (ls._ep._y-ls._sp._y)*(ls._ep._y-ls._sp._y) + (ls._ep._z-ls._sp._z)*(ls._ep._z-ls._sp._z)); }
public float Norm(LineSeg3D ls) { return (float)Math.Sqrt((ls._ep._x - ls._sp._x) * (ls._ep._x - ls._sp._x) + (ls._ep._y-ls._sp._y)*(ls._ep._y-ls._sp._y) + (ls._ep._z-ls._sp._z)*(ls._ep._z-ls._sp._z)); }
// Rotate a line segment. // @param l the line segment to be rotated // @returns the resulting rotated line segment public LineSeg3D Multiply(LineSeg3D l) { return(this.Rotate(l)); }
// Rotate a line segment. // @param l the line segment to be rotated // @returns the resulting rotated line segment public LineSeg3D Multiply (LineSeg3D l) { return (this.Rotate(l)); }
// Rotate a line segment. // @param l the line segment to be rotated // @returns the resulting rotated line segment public LineSeg3D Rotate(LineSeg3D l) { // Simply rotate both lines float angle = (float)Math.Sqrt(_x * _x + _y * _y + _z * _z); if (angle < 1e-8) { return l; } float sn = (float)Math.Sin(angle); float cs = (float)Math.Cos(angle); Vector3D axis = new Vector3D(_x / angle, _y / angle, _z / angle); Vector3D ns = new Vector3D(Point3D.VectorProduct(axis, l.StartPoint())); Vector3D ne = new Vector3D(Point3D.VectorProduct(axis, l.EndPoint())); Vector3D deltas = new Vector3D(sn * ns + (cs - 1.0f) * (Point3D.VectorProduct(ns, axis))); Vector3D deltae = new Vector3D(sn * ne + (cs - 1.0f) * (Point3D.VectorProduct(ne, axis))); return new LineSeg3D(l.StartPoint() + deltas, l.EndPoint() + deltae); }