コード例 #1
0
ファイル: MainForm.cs プロジェクト: swingfox/cube-rotation
        private _3DPoint rotZ(int deg, _3DPoint p)
        {
            double rad = deg * Math.PI / 180;

            _3DPoint result = new _3DPoint();

            result.X = Convert.ToInt32(Math.Cos(rad) * p.X - Math.Sin(rad) * p.Y);
            result.Y = Convert.ToInt32(Math.Sin(rad) * p.X + Math.Cos(rad) * p.Y);
            result.Z = p.Z;

            return(result);
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: swingfox/cube-rotation
        public MainForm()
        {
            InitializeComponent();

            for (int i = 0; i < 8; i++)
            {
                corner[i] = new _3DPoint();
                mover[i]  = new _3DPoint();
            }

            corner[0].X = side / 2;
            corner[1].X = side / 2;
            corner[2].X = -side / 2;
            corner[3].X = -side / 2;
            corner[4].X = side / 2;
            corner[5].X = side / 2;
            corner[6].X = -side / 2;
            corner[7].X = -side / 2;

            corner[0].Y = -side / 2;
            corner[1].Y = side / 2;
            corner[2].Y = side / 2;
            corner[3].Y = -side / 2;
            corner[4].Y = -side / 2;
            corner[5].Y = side / 2;
            corner[6].Y = side / 2;
            corner[7].Y = -side / 2;

            corner[0].Z = side / 2;
            corner[1].Z = side / 2;
            corner[2].Z = side / 2;
            corner[3].Z = side / 2;
            corner[4].Z = -side / 2;
            corner[5].Z = -side / 2;
            corner[6].Z = -side / 2;
            corner[7].Z = -side / 2;

            for (int i = 0; i < 8; i++)
            {
                mover[i] = rotX(thetaX, corner[i]);
                mover[i] = rotY(thetaY, mover[i]);
                mover[i] = rotZ(thetaZ, mover[i]);
            }

            pictureCube.Refresh();
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: swingfox/cube-rotation
 private Point to2D(_3DPoint p)
 {
     return(to2D(p.X, p.Y, p.Z));
 }