Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rotation"></param>
        /// <returns></returns>
        public void Set(AxisAngle3d rotation)
        {
            if (!rotation.IsValid)
            {
                return;
            }

            var axis     = rotation.Axis;
            var cosAngle = rotation.CosAngle;
            var sinAngle = rotation.SinAngle;

            var t = 1.0 - cosAngle;

            _x.X = cosAngle + axis.X * axis.X * t;
            _y.Y = cosAngle + axis.Y * axis.Y * t;
            _z.Z = cosAngle + axis.Z * axis.Z * t;

            var c = axis.X * axis.Y * t;
            var s = axis.Z * sinAngle;

            _x.Y = c + s;
            _y.X = c - s;

            c = axis.X * axis.Z * t;
            s = axis.Y * sinAngle;

            _x.Z = c - s;
            _z.X = c + s;

            c = axis.Y * axis.Z * t;
            s = axis.X * sinAngle;

            _y.Z = c + s;
            _z.Y = c - s;
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="axisAngle"></param>
        /// <returns></returns>
        public void Set(AxisAngle3d axisAngle)
        {
            var    axis = axisAngle.Axis;
            var    cos  = axisAngle.CosAngle;
            var    sin  = axisAngle.SinAngle;
            double t    = 1.0 - cos;

            _x.X = cos + axis.X * axis.X * t;
            _y.Y = cos + axis.Y * axis.Y * t;
            _z.Z = cos + axis.Z * axis.Z * t;

            double p0 = axis.X * axis.Y * t;
            double p1 = axis.Z * sin;

            _x.Y = p0 + p1;
            _y.X = p0 - p1;

            p0 = axis.X * axis.Z * t;
            p1 = axis.Y * sin;

            _x.Z = p0 - p1;
            _z.X = p0 + p1;

            p0 = axis.Y * axis.Z * t;
            p1 = axis.X * sin;

            _y.Z = p0 + p1;
            _z.Y = p0 - p1;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Assumes the given rotation is valid.
        /// </summary>
        /// <param name="rotation"></param>
        public void Set(AxisAngle3d rotation)
        {
            var axis = rotation.Axis;
            var s    = Math.Sqrt(0.5 - rotation.CosAngle); // half-angle identity

            X = axis.X * s;
            Y = axis.Y * s;
            Z = axis.Z * s;
            W = Math.Sqrt(0.5 + rotation.CosAngle); // half-angle identity
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rotation"></param>
        /// <returns></returns>
        public bool Set(ref AxisAngle3d rotation)
        {
            if (!rotation.IsValid)
            {
                return(false);
            }

            var axis     = rotation.Axis;
            var cosAngle = rotation.CosAngle;
            var sinAngle = rotation.SinAngle;

            var t = 1.0 - cosAngle;

            _x.X = cosAngle + axis.X * axis.X * t;
            _y.Y = cosAngle + axis.Y * axis.Y * t;
            _z.Z = cosAngle + axis.Z * axis.Z * t;

            var c = axis.X * axis.Y * t;
            var s = axis.Z * sinAngle;

            _x.Y = c + s;
            _y.X = c - s;

            c = axis.X * axis.Z * t;
            s = axis.Y * sinAngle;

            _x.Z = c - s;
            _z.X = c + s;

            c = axis.Y * axis.Z * t;
            s = axis.X * sinAngle;

            _y.Z = c + s;
            _z.Y = c - s;

            return(true);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Rotates this basis around the given axis by the specified angle.
 /// </summary>
 /// <param name="axisAngle"></param>
 public void Rotate(AxisAngle3d axisAngle)
 {
     SetXY(axisAngle.Rotate(_x), axisAngle.Rotate(_y));
 }
Exemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 public Rotation3d(AxisAngle3d axisAngle)
     : this()
 {
     Set(axisAngle);
 }
Exemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 public void Set(ref AxisAngle3d rotation)
 {
     SetImpl(rotation.Axis, rotation.Angle);
 }
Exemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 public Quaterniond(AxisAngle3d rotation)
     : this()
 {
     Set(ref rotation);
 }
Exemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 /// <param name="point"></param>
 /// <returns></returns>
 public static Orient3d CreateRotationAtPoint(AxisAngle3d rotation, Vec3d point)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Applies the given rotation to this object.
 /// </summary>
 /// <param name="rotation"></param>
 public void Rotate(ref AxisAngle3d rotation)
 {
     SetXY(rotation.Apply(_x), rotation.Apply(_y));
 }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 public OrthoBasis3d(AxisAngle3d rotation)
     : this()
 {
     Set(ref rotation);
 }
Exemplo n.º 12
0
 /// <summary>
 ///
 /// </summary>
 public Rotation3d(AxisAngle3d rotation)
     : this()
 {
     Set(rotation);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Applies the given rotation to the axis of this rotation.
 /// </summary>
 /// <param name="rotation"></param>
 public void RotateAxis(AxisAngle3d rotation)
 {
     _axis = rotation.Apply(_axis);
 }
Exemplo n.º 14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="other"></param>
 /// <param name="tolerance"></param>
 /// <returns></returns>
 public bool ApproxEquals(ref AxisAngle3d other, double tolerance = SlurMath.ZeroTolerance)
 {
     return
         (SlurMath.ApproxEquals(_angle, other._angle, tolerance) &&
          _axis.ApproxEquals(other._axis, tolerance));
 }