public ChickenData(
                GameObjectId id,
                Point3D position,
                double beakAngle,
                ModelVisual3D visual,
                MatrixTransform3D transform,
                BillboardTextVisual3D billboardVisual)
                : base(id, position, transform)
            {
                #region Argument Check

                if (visual == null)
                {
                    throw new ArgumentNullException("visual");
                }

                if (billboardVisual == null)
                {
                    throw new ArgumentNullException("billboardVisual");
                }

                #endregion

                this.BeakAngle       = beakAngle;
                this.Visual          = visual;
                this.BillboardVisual = billboardVisual;
            }
        private void FollowChicken()
        {
            if (!_followedChickenId.HasValue)
            {
                return;
            }

            var data = _chickenDatas.GetValueOrDefault(_followedChickenId.Value);

            if (data == null)
            {
                RestoreCameraDefaults();
                return;
            }

            var transformMatrix = Matrix3D.Identity;

            transformMatrix.Rotate(new Quaternion(new Vector3D(0d, 0d, 1d), data.BeakAngle));
            transformMatrix.Translate(data.Position.ToVector3D());

            var transform = this.Camera.Transform as MatrixTransform3D;

            if (transform == null)
            {
                transform             = new MatrixTransform3D();
                this.Camera.Transform = transform;
            }

            transform.Matrix = transformMatrix;
        }
Esempio n. 3
0
        private void Filter_FilterUpdate(object sender, EventArgs e)
        {
            Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() =>
            {
                Pitch = filter.Pitch;
                Roll  = filter.Roll;
                if (EnableYaw)
                {
                    Yaw = filter.Yaw;
                }
                else
                {
                    Yaw = 0;
                }

                var pitchRotation = new Quaternion(new Vector3D(1, 0, 0), -Pitch);
                var rollRotation  = new Quaternion(new Vector3D(0, 0, 1), Roll);
                var yawRotation   = new Quaternion(new Vector3D(0, 1, 0), -Yaw);
                var quat          = Quaternion.Multiply(Quaternion.Multiply(pitchRotation, rollRotation), yawRotation);
                var transform     = new QuaternionRotation3D(quat);
                var rot           = new RotateTransform3D(transform);
                Transform         = new MatrixTransform3D(rot.Value);



                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Pitch"));
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Roll"));
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Yaw"));
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Transform"));
            }));
        }
Esempio n. 4
0
        /// <summary>
        /// 設定轉移矩陣,將旋轉跟平移矩陣結合
        /// </summary>
        public void SetTransformMatrix()
        {
            if (IsTransformApplied)
            {
                Matrix3D transform = new Matrix3D();
                //將四元數轉乘Matrix 剛轉完需要再轉置
                transform.Rotate(_finalRotation);

                double temp;
                temp          = transform.M12;
                transform.M12 = transform.M21;
                transform.M21 = temp;

                temp          = transform.M13;
                transform.M13 = transform.M31;
                transform.M31 = temp;

                temp          = transform.M23;
                transform.M23 = transform.M32;
                transform.M32 = temp;

                transform.OffsetX = _finalTranslation.X;
                transform.OffsetY = _finalTranslation.Y;
                transform.OffsetZ = _finalTranslation.Z;

                Transform = new MatrixTransform3D(transform);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Transforms from local to world coordinates.
        /// </summary>
        /// <param name="vector">
        /// The vector (local coordinates).
        /// </param>
        /// <returns>
        /// Transformed vector (world coordinates).
        /// </returns>
        protected Vector3D ToWorld(Vector3D vector)
        {
            var mat = Visual3DHelper.GetTransform(this);
            var t   = new MatrixTransform3D(mat);

            return(t.Transform(vector));
        }
Esempio n. 6
0
    void SetHeadLight()
    {
        var matrix = view.Camera.GetInversedViewMatrix();
        var t      = new MatrixTransform3D(matrix);

        light.Transform = t;
    }
        private void RotateObject(Tuple <float, float, float> newAngles)
        {
            Matrix3D          matrix    = CalculateRotationMatrix(newAngles.Item1, newAngles.Item2, newAngles.Item3);
            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            TargetModel_.Transform = transform;
        }
Esempio n. 8
0
        public void ARotTest()
        {
            var transform = new Transform3DGroup();

            var i = new Vector3D(1, 0, 0);
            var j = new Vector3D(0, 1, 0);
            var k = new Vector3D(0, 0, 1);

            var u = new Vector3D(1, 1, 1);

            u.Normalize();
            var t = new Vector3D(-1, 1, 1);

            t.Normalize();
            var w = Vector3D.CrossProduct(u, t);

            w.Normalize();
            var v = Vector3D.CrossProduct(w, u);

            var m = new MatrixTransform3D(
                new Matrix3D(
                    u.X, u.Y, u.Z, 0.0,
                    v.X, v.Y, v.Z, 0.0,
                    w.X, w.Y, w.Z, 0.0,
                    0.0, 0.0, 0.0, 1.0));

            var source = new Point3D(Math.Sqrt(3.0), 0, 0);
            var res    = m.Transform(source);

            Assert.AreEqual(1.0, res.X, 0.01, "x");
            Assert.AreEqual(1.0, res.Y, 0.01, "y");
            Assert.AreEqual(1.0, res.Z, 0.01, "z");
        }
Esempio n. 9
0
        /// <summary>
        /// This overload will rotate arrays of different types.  Just pass null if you don't have any of that type
        /// </summary>
        public static void GetRotatedVector(this Quaternion quaternion, Vector3D[] vectors, Point3D[] points, DoubleVector[] doubleVectors)
        {
            Matrix3D matrix = new Matrix3D();

            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            if (vectors != null)
            {
                transform.Transform(vectors);
            }

            if (points != null)
            {
                transform.Transform(points);
            }

            if (doubleVectors != null)
            {
                for (int cntr = 0; cntr < doubleVectors.Length; cntr++)
                {
                    doubleVectors[cntr] = new DoubleVector(transform.Transform(doubleVectors[cntr].Standard), transform.Transform(doubleVectors[cntr].Orth));
                }
            }
        }
Esempio n. 10
0
        public static MatrixTransform3D Rotate3D(Transform3D transform, double x, double y, double z, Point3D center, Vector3D up, Vector3D look, RotationType type)
        {
            if (type != RotationType.LockAxisY)
            {
                up = transform.Transform(up);
            }
            if (type != RotationType.LockAxisZ)
            {
                look = transform.Transform(look);
            }
            center = transform.Transform(center);
            Vector3D axisX  = Vector3D.CrossProduct(up, look);
            Matrix3D matrix = new Matrix3D();

            matrix.RotateAt(new Quaternion(axisX, x), center);
            matrix.RotateAt(new Quaternion(up, y), center);
            matrix.RotateAt(new Quaternion(look, z), center);
            MatrixTransform3D mOriginTransform = transform as MatrixTransform3D;

            //mOriginTransform.Matrix.RotateAt(
            try
            {
                return(new MatrixTransform3D(Matrix3D.Multiply(mOriginTransform.Matrix, matrix)));
            }
            catch (Exception err)
            {
                Exceptions.LogOnly(err);
                return(null);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 將BoneModel物件反序列化的過程
        /// </summary>
        public BoneModel(SerializationInfo info, StreamingContext context)
        {
            IsRendering        = (bool)info.GetValue("IsRendering", typeof(bool));
            SafeFileName       = (string)info.GetValue("SafeFileName", typeof(string));
            MarkerId           = (string)info.GetValue("MarkerId", typeof(string));
            ModelCenter.X      = (float)info.GetValue("ModelCenter_X", typeof(float));
            ModelCenter.Y      = (float)info.GetValue("ModelCenter_Y", typeof(float));
            ModelCenter.Z      = (float)info.GetValue("ModelCenter_Z", typeof(float));
            IsTransformApplied = (bool)info.GetValue("IsTransformApplied", typeof(bool));
            ModelType          = (ModelType)info.GetValue("ModelType", typeof(ModelType));
            Matrix3D matrix = new Matrix3D();

            matrix.M11     = (double)info.GetValue("M11", typeof(double)); matrix.M12 = (double)info.GetValue("M12", typeof(double)); matrix.M13 = (double)info.GetValue("M13", typeof(double)); matrix.M14 = (double)info.GetValue("M14", typeof(double));
            matrix.M21     = (double)info.GetValue("M21", typeof(double)); matrix.M22 = (double)info.GetValue("M22", typeof(double)); matrix.M23 = (double)info.GetValue("M23", typeof(double)); matrix.M24 = (double)info.GetValue("M24", typeof(double));
            matrix.M31     = (double)info.GetValue("M31", typeof(double)); matrix.M32 = (double)info.GetValue("M32", typeof(double)); matrix.M33 = (double)info.GetValue("M33", typeof(double)); matrix.M34 = (double)info.GetValue("M34", typeof(double));
            matrix.OffsetX = (double)info.GetValue("M41", typeof(double)); matrix.OffsetY = (double)info.GetValue("M42", typeof(double)); matrix.OffsetZ = (double)info.GetValue("M43", typeof(double)); matrix.M44 = (double)info.GetValue("M44", typeof(double));
            Transform      = new MatrixTransform3D(matrix);
            Color boneColor = new Color();

            boneColor.A      = (byte)info.GetValue("boneColor_A", typeof(byte));
            boneColor.R      = (byte)info.GetValue("boneColor_R", typeof(byte));
            boneColor.G      = (byte)info.GetValue("boneColor_G", typeof(byte));
            boneColor.B      = (byte)info.GetValue("boneColor_B", typeof(byte));
            BoneDiffuseColor = boneColor;
        }
Esempio n. 12
0
        public static void Rotate(this MatrixTransform3D transform, Vector3D axis, double angle)
        {
            var matrix = transform.Matrix;

            matrix.Rotate(new Quaternion(axis, angle));
            transform.Matrix = matrix;
        }
Esempio n. 13
0
        internal void Update()
        {
            m_forearmSystem.Model.Transform = m_arm.ForearmTransform;
            m_wristSystem.Model.Transform   = m_arm.WristTransform;

            // now, distribute the circle/ellipses
            Quaternion adjustedForearm = m_arm.ForearmOrientation
                                         * (new Quaternion(new Vector3D(0.0, 0.0, 1.0), -90.0));

            for (int i = 0; i <= Constants.NumberOfArmLengthSegments; i++)
            {
                double factor = (double)i / Constants.NumberOfArmLengthSegments;

                Point3D    center      = m_arm.ForearmCenter + factor * (m_arm.WristCenter - m_arm.ForearmCenter);
                Quaternion orientation = Quaternion.Slerp(adjustedForearm, m_arm.WristOrientation, factor);

                Transform3DGroup transformGroup = new Transform3DGroup();
                transformGroup.Children.Add(new RotateTransform3D(new QuaternionRotation3D(orientation)));
                transformGroup.Children.Add(new TranslateTransform3D(center.X, center.Y, center.Z));

                MatrixTransform3D transform = new MatrixTransform3D(transformGroup.Value);
                for (int j = 0; j <= Constants.NumberOfArmShapeSegments; j++)
                {
                    Point3D transformedPt = transform.Transform(m_ellipsePts[i][j]);
                    m_mesh.Positions[j + i * (Constants.NumberOfArmShapeSegments + 1)] = transformedPt;
                }
            }
        }
Esempio n. 14
0
        public static void RotateAt(this MatrixTransform3D transform, Vector3D axis, double angle, Point3D center)
        {
            var matrix = transform.Matrix;

            matrix.RotateAt(new Quaternion(axis, angle), center);
            transform.Matrix = matrix;
        }
Esempio n. 15
0
        public Point3D?NearestPoint2D(Point3D cameraPoint)
        {
            double  closest      = double.MaxValue;
            Point3D?closestPoint = null;

            Matrix3D matrix;

            if (!MathUtils.ToViewportTransform(this, out matrix))
            {
                return(null);
            }

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            foreach (Point3D point in this.Points)
            {
                Point3D cameraSpacePoint = transform.Transform(point);
                cameraSpacePoint.Z = cameraSpacePoint.Z * 100;

                Vector3D dir = cameraPoint - cameraSpacePoint;
                if (dir.Length < closest)
                {
                    closest      = dir.Length;
                    closestPoint = point;
                }
            }

            return(closestPoint);
        }
Esempio n. 16
0
        /// <summary>
        /// Transforms from local to world coordinates.
        /// </summary>
        /// <param name="point">
        /// The point (local coordinates).
        /// </param>
        /// <returns>
        /// Transformed point (world coordinates).
        /// </returns>
        protected Point3D ToWorld(Point3D point)
        {
            var mat = Visual3DHelper.GetTransform(this);
            var t   = new MatrixTransform3D(mat);

            return(t.Transform(point));
        }
Esempio n. 17
0
        public void RenderActor(SceneActor item)
        {
            if (VisualFactory == null)
            {
                DebugUtil.LogWithLocation("No visual factory provided for viewport");
            }
            else
            {
                Visual3D visual;
                //Check if we need to use a dummy visual
                if (item.Geometry != null)
                {
                    visual = VisualFactory.GetVisual(RenderingMode.Solid, item);
                }
                else
                {
                    visual = VisualFactory.GetDummyVisual();
                }

                actorsVisuals.Add(new Tuple <LibTransform, Visual3D>(item.Transform, visual));

                //Set a position for the visual
                AegirLib.MathType.Matrix m = item.Transform.TransformMatrix;
                Matrix3D matrix            = new Matrix3D(m.M11, m.M12, m.M13, m.M14,
                                                          m.M21, m.M22, m.M23, m.M24,
                                                          m.M31, m.M32, m.M33, m.M34,
                                                          m.M41, m.M42, m.M43, m.M44);

                MatrixTransform3D matrixTransform = new MatrixTransform3D(matrix);
                visual.Transform = matrixTransform;

                Scene.Children.Add(visual);
            }
        }
Esempio n. 18
0
        public ModelVisual3D MakeVisualModel(MDagPath path)
        {
            var mesh = new MFnMesh(path);
            var r    = new ModelVisual3D();

            r.Content   = MakeModel(mesh);
            r.Transform = new Transform3DGroup();
            Transform3DGroup transformGroup = r.Transform as Transform3DGroup;

            MTransformationMatrix matrix = new MTransformationMatrix(path.inclusiveMatrix);
            //MVector tr =matrix.getTranslation (MSpace.Space.kWorld) ;
            //TranslateTransform3D translation =new TranslateTransform3D (tr.x, tr.y, tr.z) ;
            //transformGroup.Children.Add (translation) ;

            //double x =0, y =0, z =0, w =0 ;
            //matrix.getRotationQuaternion (ref x, ref y, ref z, ref w, MSpace.Space.kWorld) ;
            //QuaternionRotation3D rotation =new QuaternionRotation3D (new Quaternion (x, y, z, w)) ;
            //transformGroup.Children.Add (new RotateTransform3D (rotation)) ;

            //double [] scales =new double [3] ;
            //matrix.getScale (scales, MSpace.Space.kWorld) ;
            //ScaleTransform3D scale =new ScaleTransform3D (scales [0], scales [1], scales [2]) ;
            //transformGroup.Children.Add (scale) ;

            MMatrix  mat      = matrix.asMatrixProperty;
            Matrix3D matrix3d = new Matrix3D(mat [0, 0], mat [0, 1], mat [0, 2], mat [0, 3],
                                             mat [1, 0], mat [1, 1], mat [1, 2], mat [1, 3],
                                             mat [2, 0], mat [2, 1], mat [2, 2], mat [2, 3],
                                             mat [3, 0], mat [3, 1], mat [3, 2], mat [3, 3]);
            MatrixTransform3D matrixTransform = new MatrixTransform3D(matrix3d);

            transformGroup.Children.Add(matrixTransform);

            return(r);
        }
Esempio n. 19
0
        private static Transform3D CombineTransform(Transform3D parent, Transform3D child)
        {
            Transform3D finalTransform;

            if (parent == null || parent.Value.IsIdentity)
            {
                if (child == null || child.Value.IsIdentity)
                {
                    finalTransform = null;
                }
                else
                {
                    finalTransform = child;
                }
            }
            else
            {
                if (child == null || child.Value.IsIdentity)
                {
                    finalTransform = parent;
                }
                else
                {
                    finalTransform = new MatrixTransform3D(child.Value * parent.Value); // First apply child and than parent transform
                }
            }

            return(finalTransform);
        }
Esempio n. 20
0
        public static GeometryModel3D[] GetModels(CoordinateSystem cs)
        {
            var tg = new MatrixTransform3D(cs.Transformation);

            List <GeometryModel3D> models = new List <GeometryModel3D>();

            int i = 1;

            var scale = (cs.Transformation.ToMatrix().Row1.Length() +
                         cs.Transformation.ToMatrix().Row2.Length() +
                         cs.Transformation.ToMatrix().Row3.Length()) / 3;

            foreach (var correspondence in cs.Correspondences)
            {
                var m = ViewportHelper.GetSphere(correspondence.LocalCoordinateSystem, 0.1 / scale, new PhongMaterial()
                {
                    AmbientColor = new Color(LUT.Colors[i, 0], LUT.Colors[i, 1], LUT.Colors[i, 2]),
                    DiffuseColor = new Color(LUT.Colors[i, 0], LUT.Colors[i, 1], LUT.Colors[i, 2])
                });
                m.Transform = tg;
                models.Add(m);

                var n = ViewportHelper.GetSphere(correspondence.ParentCoordinateSystem, 0.08, new PhongMaterial()
                {
                    AmbientColor = new Color(LUT.Colors[i, 0] - 5, LUT.Colors[i, 1] - 5, LUT.Colors[i, 2] - 5),
                    DiffuseColor = new Color(LUT.Colors[i, 0] - 5, LUT.Colors[i, 1] - 5, LUT.Colors[i, 2] - 5)
                });
                models.Add(n);

                i++;
            }

            return(models.ToArray());
        }
Esempio n. 21
0
        /// <summary>
        /// The sort children.
        /// </summary>
        private void SortChildren()
        {
            var vp = Visual3DHelper.GetViewport3D(this);

            if (vp == null)
            {
                return;
            }

            var cam = vp.Camera as ProjectionCamera;

            if (cam == null)
            {
                return;
            }

            var cameraPos = cam.Position;
            var transform = new MatrixTransform3D(Visual3DHelper.GetTransform(this));

            IList <Visual3D> transparentChildren = new List <Visual3D>();
            IList <Visual3D> opaqueChildren      = new List <Visual3D>();

            if (this.CheckForOpaqueVisuals)
            {
                foreach (var child in this.Children)
                {
                    if (this.IsVisualTransparent(child))
                    {
                        transparentChildren.Add(child);
                    }
                    else
                    {
                        opaqueChildren.Add(child);
                    }
                }
            }
            else
            {
                transparentChildren = this.Children;
            }

            // sort the children by distance from camera (note that OrderBy is a stable sort algorithm)
            var sortedTransparentChildren =
                transparentChildren.OrderBy(item => - this.GetCameraDistance(item, cameraPos, transform)).ToList();

            this.Children.Clear();

            // add the opaque children
            foreach (var c in opaqueChildren)
            {
                this.Children.Add(c);
            }

            // add the sorted transparent children
            foreach (var c in sortedTransparentChildren)
            {
                this.Children.Add(c);
            }
        }
Esempio n. 22
0
        public void Update()
        {
            // change the coordinate systems
            Transform3DGroup forearmMarkerTransformGroup = new Transform3DGroup();

            forearmMarkerTransformGroup.Children.Add(new RotateTransform3D(
                                                         new QuaternionRotation3D(m_forearmOrientation)));
            forearmMarkerTransformGroup.Children.Add(new TranslateTransform3D(
                                                         m_forearmPosition.X, m_forearmPosition.Y, m_forearmPosition.Z));

            Transform3DGroup wristMarkerTransformGroup = new Transform3DGroup();

            wristMarkerTransformGroup.Children.Add(new RotateTransform3D(
                                                       new QuaternionRotation3D(m_wristOrientation)));
            wristMarkerTransformGroup.Children.Add(new TranslateTransform3D(
                                                       m_wristPosition.X, m_wristPosition.Y, m_wristPosition.Z));

            m_forearmTransform = forearmMarkerTransformGroup;
            m_wristTransform   = wristMarkerTransformGroup;

            // calculate the local transformations
            double forearmRadius = m_armCircumference / (2.0 * Math.PI);

            Vector3D forearmOffsetVector = new Vector3D(0.0, -forearmRadius, 0.0);
            Vector3D wristOffsetVector   = new Vector3D(-(m_wristWidth / 2.0), m_wristHeight / 2.0, 0.0);

            Transform3DGroup forearmTransformGroup = new Transform3DGroup();

            forearmTransformGroup.Children.Add(new TranslateTransform3D(
                                                   forearmOffsetVector.X, forearmOffsetVector.Y, forearmOffsetVector.Z));
            forearmTransformGroup.Children.Add(new RotateTransform3D(
                                                   new QuaternionRotation3D(m_forearmOrientation)));
            forearmTransformGroup.Children.Add(new TranslateTransform3D(
                                                   m_forearmPosition.X, m_forearmPosition.Y, m_forearmPosition.Z));
            MatrixTransform3D forearmTransform = new MatrixTransform3D(forearmTransformGroup.Value);

            Transform3DGroup wristTransformGroup = new Transform3DGroup();

            wristTransformGroup.Children.Add(new TranslateTransform3D(
                                                 wristOffsetVector.X, wristOffsetVector.Y, wristOffsetVector.Z));
            wristTransformGroup.Children.Add(new RotateTransform3D(
                                                 new QuaternionRotation3D(m_wristOrientation)));
            wristTransformGroup.Children.Add(new TranslateTransform3D(
                                                 m_wristPosition.X, m_wristPosition.Y, m_wristPosition.Z));
            MatrixTransform3D wristTransform = new MatrixTransform3D(wristTransformGroup.Value);

            m_forearmCenter = forearmTransform.Transform(new Point3D(0.0, 0.0, 0.0));  // now, it is in world coordinates
            m_wristCenter   = wristTransform.Transform(new Point3D(0.0, 0.0, 0.0));    // now, it is in world coordinates

            if (Constants.DebugPrint)
            {
                Debug.WriteLine("Forearm [CENTER]:  " + m_forearmCenter);
                Debug.WriteLine("Forearm [QUAT.]:   " + m_forearmOrientation.Axis + " (" + m_forearmOrientation.Angle + ")");
                Debug.WriteLine("Wrist [CENTER]:    " + m_wristCenter);
            }

            m_model.Update();
        }
        private void Rotate(double angle, ModelVisual3D model, Vector3D vector)
        {
            var matrix = model.Transform.Value;

            matrix.Rotate(new Quaternion(vector, angle));
            var transform = new MatrixTransform3D(matrix);

            model.Transform = transform;
        }
Esempio n. 24
0
        /// <summary>
        /// Transforms from world to local coordinates.
        /// </summary>
        /// <param name="worldPoint">
        /// The point (world coordinates).
        /// </param>
        /// <returns>
        /// Transformed vector (local coordinates).
        /// </returns>
        protected Point3D ToLocal(Point3D worldPoint)
        {
            var mat = Visual3DHelper.GetTransform(this);

            mat.Invert();
            var t = new MatrixTransform3D(mat);

            return(t.Transform(worldPoint));
        }
Esempio n. 25
0
        public static DoubleVector GetRotatedVector(this Quaternion quaternion, DoubleVector doubleVector)
        {
            Matrix3D matrix = new Matrix3D();

            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            return(new DoubleVector(transform.Transform(doubleVector.Standard), transform.Transform(doubleVector.Orth)));
        }
Esempio n. 26
0
        /// <summary>
        /// Rotates the vector around the angle in degrees
        /// </summary>
        public static Vector3D GetRotatedVector(this Vector3D vector, Vector3D axis, double angle)
        {
            Matrix3D matrix = new Matrix3D();

            matrix.Rotate(new Quaternion(axis, angle));

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            return(transform.Transform(vector));
        }
Esempio n. 27
0
        // I copy the code in each of these overloads, rather than make a private method to increase speed
        //TODO: I don't use these rotate extension methods anymore, but it would be worth testing whether to use this matrix transform, or use: new RotateTransform3D(new QuaternionRotation3D(quaternion))
        public static Vector3D GetRotatedVector(this Quaternion quaternion, Vector3D vector)
        {
            Matrix3D matrix = new Matrix3D();

            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            return(transform.Transform(vector));
        }
Esempio n. 28
0
        public static Point3D GetRotatedVector(this Quaternion quaternion, Point3D point)
        {
            Matrix3D matrix = new Matrix3D();

            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            return(transform.Transform(point));
        }
Esempio n. 29
0
        public static void GetRotatedVector(this Quaternion quaternion, Point3D[] points)
        {
            Matrix3D matrix = new Matrix3D();

            matrix.Rotate(quaternion);

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            transform.Transform(points);
        }
Esempio n. 30
0
        /// <summary>
        /// Rotates the double vector around the angle in degrees
        /// </summary>
        public DoubleVector GetRotatedVector(Vector3D axis, double angle)
        {
            Matrix3D matrix = new Matrix3D();

            matrix.Rotate(new Quaternion(axis, angle));

            MatrixTransform3D transform = new MatrixTransform3D(matrix);

            return(new DoubleVector(transform.Transform(this.Standard), transform.Transform(this.Orth)));
        }