internal void FindDistances(PointXYZ pointXYZ)
 {
     for (int index = 0; index < _graphicObjects.Count; index++)
     {
         _graphicObjects[index].FindDistance(pointXYZ);
     }
 }
        private void ProceedArrayPoints()
        {
            var gos = new List <GraphicObject>();

            var length = Points3D.Length - 1;

            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < length; j++)
                {
                    var points    = new Point[4];
                    var pointsXYZ = new PointXYZ[4];
                    pointsXYZ[0] = FindPoint2DAndAddToArray(points, 0, i, j);
                    pointsXYZ[1] = FindPoint2DAndAddToArray(points, 1, i + 1, j);
                    pointsXYZ[2] = FindPoint2DAndAddToArray(points, 2, i + 1, j + 1);
                    pointsXYZ[3] = FindPoint2DAndAddToArray(points, 3, i, j + 1);

                    gos.Add(new GraphicObject(GraphicObjectType.Polygon, pointsXYZ)
                    {
                        Color = GetColor(pointsXYZ), Pen = _penPolygonLines
                    });
                }
            }

            _graphicObjects.Add(gos);
        }
        private void ProceedAxis()
        {
            var initialPoint = new PointXYZ(0, 0, 0);

            var gos = new List <GraphicObject>();

            gos.Add(new GraphicObject(GraphicObjectType.Line, initialPoint, new PointXYZ(_axis, 0, 0))
            {
                Pen = _penAxis
            });
            gos.Add(new GraphicObject(GraphicObjectType.Line, initialPoint, new PointXYZ(0, _axis, 0))
            {
                Pen = _penAxis
            });
            gos.Add(new GraphicObject(GraphicObjectType.Line, initialPoint, new PointXYZ(0, 0, _axis))
            {
                Pen = _penAxis
            });

            gos.Add(new GraphicObject(GraphicObjectType.String, new PointXYZ(_axis, 0, 0))
            {
                String = NameAxisX, Color = Color.Black, Font = _fontAxis
            });
            gos.Add(new GraphicObject(GraphicObjectType.String, new PointXYZ(0, _axis, 0))
            {
                String = NameAxisY, Color = Color.Black, Font = _fontAxis
            });
            gos.Add(new GraphicObject(GraphicObjectType.String, new PointXYZ(0, 0, _axis))
            {
                String = NameAxisZ, Color = Color.Black, Font = _fontAxis
            });

            _graphicObjects.Add(gos);
        }
        private void FindInitPoint()
        {
            var s = _side / 2;

            _initPoint = new Point(s, s);

            var ha = _hAngle;

            _hAngle = Math.PI + ha;
            var va = _vAngle;

            _vAngle = Math.PI + va;

            var a  = _axis / 2;
            var ip = new PointXYZ(a, a, -a);

            var p = GraphicObject.GetPoint(ip, _initPoint, _hAngle, _vAngleSin, _vAngleCos);

            _initPoint = new Point(p.X, p.Y);

            _hAngle = ha;
            _vAngle = va;

            ip            = new PointXYZ(ip.X, ip.Y, ip.Z + _axis);
            _specPointXYZ = new PointXYZ(
                ip.X + _axis * Math.Sin(_hAngle) * _vAngleCos,
                ip.Y + _axis * Math.Cos(_hAngle) * _vAngleCos,
                ip.Z - _axis * Math.Sin(_vAngle));

            _graphicObjects.Add(new GraphicObject(GraphicObjectType.Line, _specPointXYZ, ip)
            {
                Pen = new Pen(Color.Red, 4)
            });
        }
        internal void FindDistance(PointXYZ pointXYZ)
        {
            double distanceSum = 0;

            for (int index = 0; index < PointXYZs.Length; index++)
            {
                var point = PointXYZs[index];
                var dist  = Math.Sqrt(Math.Pow(pointXYZ.X - point.X, 2) + Math.Pow(pointXYZ.Y - point.Y, 2) + Math.Pow(pointXYZ.Z - point.Z, 2));
                distanceSum += dist;
                if (dist > Distance)
                {
                    Distance = dist;
                }
            }
        }
        internal static Point GetPoint(PointXYZ pointXYZ,
                                       Point initialPoint,
                                       double horizontalAngle,
                                       double verticalAngleSin,
                                       double verticalAngleCos)
        {
            double d2X = initialPoint.X;
            double d2Y = initialPoint.Y;

            double rXY     = Math.Sqrt(Math.Pow(pointXYZ.X, 2) + Math.Pow(pointXYZ.Y, 2));
            double fiXY    = rXY == 0 ? 0 : Math.Sign(pointXYZ.Y) * Math.Acos(pointXYZ.X / rXY) + horizontalAngle;
            var    cosFiXY = Math.Cos(fiXY);
            var    sinFiXY = Math.Sin(fiXY);
            var    dXYx    = rXY * cosFiXY;
            var    dXYy    = rXY * sinFiXY;

            var dXZy = dXYy * verticalAngleSin + pointXYZ.Z * verticalAngleCos;

            d2X += dXYx;
            d2Y -= dXZy;

            return(new Point(Convert.ToInt32(d2X), Convert.ToInt32(d2Y)));
        }