Пример #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            _Point p = new _Point(Convert.ToDouble(textBox1.Text), Convert.ToDouble(textBox2.Text), Convert.ToDouble(textBox3.Text));
            _Point v = new _Point(Convert.ToDouble(textBox4.Text), Convert.ToDouble(textBox5.Text), Convert.ToDouble(textBox6.Text));

            label4.Text = VectMath.RotateByAngle(p, v, Convert.ToDouble(textBox7.Text)).x.ToString() + ", " + VectMath.RotateByAngle(p, v, Convert.ToDouble(textBox7.Text)).y.ToString() + ", " + VectMath.RotateByAngle(p, v, Convert.ToDouble(textBox7.Text)).z.ToString();
        }
Пример #2
0
 public void Rotate(_Point axis, double deg)
 {
     for (int i = 0; i < Points.Count; i++)
     {
         Points[i] = VectMath.Add(VectMath.RotateByAngle(VectMath.Subtract(Points[i], Position), axis, deg), Position);
     }
     Normal = CalculateNormal();
 }
Пример #3
0
    public Brush PerceivedColor(LightSource light, _Point CamPosition)
    {
        _Point     LightVector = VectMath.Subtract(this.Position, light.Position);
        _Point     PercVector  = this.Position;
        _Point     Rvector     = VectMath.RotateByAngle(VectMath.Negate(LightVector), Normal, 180);
        double     whitefactor = Math.Abs(.5 * Math.Sin(VectMath.AngleBetween(Normal, LightVector)) + .5);
        double     colorfactor = Math.Abs(Math.Cos(VectMath.AngleBetween(Normal, LightVector)));
        double     Total       = Math.Pow(Math.Sin(VectMath.AngleBetween(PercVector, Rvector)), 2);
        SolidBrush brush       = new SolidBrush(Color.FromArgb(Convert.ToInt32(255 * Total * colorfactor * whitefactor), Convert.ToInt32(255 * Total * whitefactor), Convert.ToInt32(255 * Total * whitefactor)));

        return(brush);
    }
Пример #4
0
 public void Rotate(_Point axis, double angle)
 {
     foreach (Plane plane in Planes)
     {
         for (int i = 0; i < plane.Points.Count; i++)
         {
             _Point p = plane.Points[i];
             //IO.Point(p);
             plane.Points[i] = VectMath.Add(VectMath.RotateByAngle(VectMath.Subtract(p, this.Position), axis, angle), this.Position);
             //IO.Point(plane.Points[i]);
         }
         plane.Position = VectMath.CenterofPoints(plane.Points);
         plane.Normal   = plane.CalculateNormal();
     }
 }
Пример #5
0
        public Point convert2D(_Point p)
        {
            if (Camera1.NormalAxis != Axes.Z)
            {
                //IO.Point(p);
                p = VectMath.RotateByAngle(p, VectMath.Cross(Axes.Z, Camera1.NormalAxis), 180 * (VectMath.AngleBetween(new _Point(0, 0, 1), Camera1.NormalAxis)) / Math.PI);
                //IO.Point(p);
            }
            //if( Camera1.VerticalAxis != Axes.Y)
            // {
            //     p = VectMath.RotateByAngle(p, Camera1.NormalAxis, 180*(VectMath.AngleBetween(new _Point(0, 1, 0), Camera1.VerticalAxis))/Math.PI);
            // }
            if (p.z <= 0)
            {
                return(new Point(0, 0));
            }
            int Xcoord = Convert.ToInt32((p.x * Globals.BMSize.Width / 2) / (p.z * Math.Tan(45))) + Globals.BMSize.Width / 2;
            int Ycoord = Convert.ToInt32((-p.y * Globals.BMSize.Height / 2) / (p.z * Math.Tan(45))) + Globals.BMSize.Height / 2;

            p.PF = new PointF(Xcoord, Ycoord);

            return(new Point(Xcoord, Ycoord));
        }
Пример #6
0
 public void Rotate(_Point Axis, double Angle)
 {
     NormalAxis   = VectMath.RotateByAngle(NormalAxis, Axis, Angle);
     VerticalAxis = VectMath.RotateByAngle(VerticalAxis, Axis, Angle);
 }