示例#1
0
        /// <summary>
        /// Create a new rotation matrix based on a rotation axis and an angle.
        /// </summary>
        /// <param name="axis">Axis around which the rotation is executed</param>
        /// <param name="angle">Angle of the clockwise rotation.</param>
        public RotationMatrix3d(Cartesian3dCoordinate axis, double angle)
        {
            // Angle is reverse to provide a clockwise rotation.
            double c = Trigonometry.Cos(-angle);
            double s = Trigonometry.Sin(-angle);
            double t = 1.0 - c;

            // Need to use normalised vector.
            axis = axis.Normalize();

            // Create the matrix
            m_Matrix = new double[3, 3];

            m_Matrix[0, 0] = c + (axis.X * axis.X * t);
            m_Matrix[1, 1] = c + (axis.Y * axis.Y * t);
            m_Matrix[2, 2] = c + (axis.Z * axis.Z * t);

            double part1 = axis.X * axis.Y * t;
            double part2 = axis.Z * s;

            m_Matrix[1, 0] = part1 + part2;
            m_Matrix[0, 1] = part1 - part2;

            part1          = axis.X * axis.Z * t;
            part2          = axis.Y * s;
            m_Matrix[2, 0] = part1 - part2;
            m_Matrix[0, 2] = part1 + part2;

            part1          = axis.Y * axis.Z * t;
            part2          = axis.X * s;
            m_Matrix[2, 1] = part1 + part2;
            m_Matrix[1, 2] = part1 - part2;
        }
示例#2
0
        private void Sin(object sender, RoutedEventArgs e)
        {
            String inputDataA = tbA.Text;

            try
            {
                double       dataA  = Double.Parse(inputDataA);
                Trigonometry s      = new Trigonometry(dataA);
                double       result = s.Sin();

                resultat.Text = result.ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("Numbers, Mayson, what are they meaning?..", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public void SinTest_double()
        {
            const int offx = 5;
            const int offy = 10;

            foreach (int length in new[] { 24, 128 })
            {
                double[] x0 = this.random.Generate(length);
                double[] y0 = this.random.Generate(length);

                // not-in-place
                double[] y     = y0.ToArray();
                int      count = length - Math.Max(offx, offy) - 2;
                Trigonometry.Sin(count, x0, offx, y, offy);
                GenixAssert.AreArraysEqual(y0.Select((a, i) => i.Between(offy, offy + count - 1) ? (double)Math.Sin(x0[i - offy + offx]) : a).ToArray(), y);

                // in-place
                double[] x = x0.ToArray();
                count = length - offx - 2;
                Trigonometry.Sin(count, x, offx);
                GenixAssert.AreArraysEqual(x0.Select((a, i) => i.Between(offx, offx + count - 1) ? (double)Math.Sin(a) : a).ToArray(), x);
            }
        }
示例#4
0
 public void ShouldComputeSinInRadians()
 {
     Assert.AreEqual(Trigonometry.Sin(90), 1);
 }
示例#5
0
 public void ValidateSinForDegrees(double degrees, double expected)
 {
     Assert.Equal(expected, Trigonometry.Sin(degrees));
 }