public void Vector3dCloneWorks()
        {
            var v  = new Vector3d(1, 2, 3);
            var v2 = v.Clone();

            v2.X = 3;

            Assert.NotEqual(v, v2);
            Assert.True(v.Equivalent(new Vector3d(1, 2, 3)));
        }
        public static Vector3d Normalise(this Vector3d vector)
        {
            double x = vector.X;
            double y = vector.Y;
            double z = vector.Z;
            double d = Math.Sqrt(x * x + y * y + z * z);

            if (d == 0)
            {
                return(vector.Clone());
            }

            return(new Vector3d {
                X = x / d, Y = y / d, Z = z / d
            });
        }
Beispiel #3
0
 /**
  * Constructor for a ray
  *
  * @param direction direction ray
  * @param point beginning of the ray
  */
 public Line(Vector3d direction, Point3d point)
 {
     this.direction = direction.Clone();
     this.point = point.Clone();
     direction.normalize();
 }
Beispiel #4
0
 /**
  * Sets a new direction
  *
  * @param direction new direction
  */
 public void setDirection(Vector3d direction)
 {
     this.direction = direction.Clone();
 }