Beispiel #1
0
        public RayInfo(Point one, Point two)
        {
            Origin = one;
            SpectVector temp = new SpectVector(one, two);

            RayVector = temp.GetNormalizationVector();
        }
Beispiel #2
0
        /// <summary>
        ///求两个向量的中间向量
        /// </summary>
        public SpectVector GetMiddleVectorOfTwoVectors(SpectVector otherVector)
        {
            SpectVector unitVector1 = this.GetNormalizationVector();
            SpectVector unitVector2 = otherVector.GetNormalizationVector();

            return(new SpectVector((unitVector1.a + unitVector2.a) / 2, (unitVector1.b + unitVector2.b) / 2, (unitVector1.c + unitVector2.c) / 2));
        }
Beispiel #3
0
        public SpectVector GetRightRotationVector(SpectVector vector, double rotationAngle)
        {
            double[] normalizations   = new double[4];
            double[] rotateparameters = new double[9];
            //normalizations中四个值分别为:旋转轴的单位方向向量三个分量x,y,z,和旋转角度弧度值。
            SpectVector rotationVector = vector.GetNormalizationVector();

            normalizations[0] = rotationVector.a;
            normalizations[1] = rotationVector.b;
            normalizations[2] = rotationVector.c;
            normalizations[3] = rotationAngle / 180 * Math.PI;//转换为弧度值
            //旋转矩阵
            rotateparameters[0] = Math.Cos(normalizations[3]) + normalizations[0] * normalizations[0] * (1 - Math.Cos(normalizations[3]));
            rotateparameters[1] = normalizations[0] * normalizations[1] * (1 - Math.Cos(normalizations[3])) + normalizations[2] * Math.Sin(normalizations[3]);
            rotateparameters[2] = normalizations[0] * normalizations[2] * (1 - Math.Cos(normalizations[3])) - normalizations[1] * Math.Sin(normalizations[3]);
            rotateparameters[3] = normalizations[0] * normalizations[1] * (1 - Math.Cos(normalizations[3])) - normalizations[2] * Math.Sin(normalizations[3]);
            rotateparameters[4] = Math.Cos(normalizations[3]) + normalizations[1] * normalizations[1] * (1 - Math.Cos(normalizations[3]));
            rotateparameters[5] = normalizations[1] * normalizations[2] * (1 - Math.Cos(normalizations[3])) + normalizations[0] * Math.Sin(normalizations[3]);
            rotateparameters[6] = normalizations[0] * normalizations[2] * (1 - Math.Cos(normalizations[3])) + normalizations[1] * Math.Sin(normalizations[3]);
            rotateparameters[7] = normalizations[1] * normalizations[2] * (1 - Math.Cos(normalizations[3])) - normalizations[0] * Math.Sin(normalizations[3]);
            rotateparameters[8] = Math.Cos(normalizations[3]) + normalizations[2] * normalizations[2] * (1 - Math.Cos(normalizations[3]));
            double xtemp = this.a * rotateparameters[0] + this.b * rotateparameters[3] + this.c * rotateparameters[6];
            double ytemp = this.a * rotateparameters[1] + this.b * rotateparameters[4] + this.c * rotateparameters[7];
            double ztemp = this.a * rotateparameters[2] + this.b * rotateparameters[5] + this.c * rotateparameters[8];

            return(new SpectVector(xtemp, ytemp, ztemp));
        }