Example #1
0
 private TDPoint GetCurrentPoint(TDPointD start, long step)
 {
     if (Camera.Direction == Direction.Front)
     {
         return new TDPoint()
                {
                    X = (long)Math.Round(start.X - step * Camera.NormalSingleVector.X), Y = (long)Math.Round(start.Y - step * Camera.NormalSingleVector.Y), Z = (long)Math.Round(start.Z - step * Camera.NormalSingleVector.Z)
                }
     }
     ;
     else
     {
         return new TDPoint()
                {
                    X = (long)Math.Round(start.X + step * Camera.NormalSingleVector.X), Y = (long)Math.Round(start.Y + step * Camera.NormalSingleVector.Y), Z = (long)Math.Round(start.Z + step * Camera.NormalSingleVector.Z)
                }
     };
 }
Example #2
0
        private Color GetOrthogonalProjectionPixelColor(long x, long y)
        {
            Color result = Colors.Transparent;

            TDPointD start = Camera.GetOffsetStartCoordinates(x, y); // Координаты текущей точки, при step = 0, это координаты точки на приёмной матрице.

            TDPoint current;

            for (long step = 1; step <= Camera.MaxDistance; step++)
            {
                current = GetCurrentPoint(start, step);

                //  Если текущая точка луча ударилась, то определяем цвет от ударившуюся поверность и её окружение по пути:
                if (IsObjectInCurrentPoint(current))
                {
                    result = GetColor(current);
                    break;
                }
            }

            return(result);
        }
Example #3
0
        public TDPointD GetOffsetStartCoordinates(long x, long y)
        {
            TDPointD result = new TDPointD();

            TDPointD top = new TDPointD(), bottom = new TDPointD();

            double tx = x / (double)(Width - 1);
            double ty = y / (double)(Height - 1);

            top.X = TopLeft.X * (1 - tx) + TopRight.X * tx;
            top.Y = TopLeft.Y * (1 - tx) + TopRight.Y * tx;
            top.Z = TopLeft.Z * (1 - tx) + TopRight.Z * tx;

            bottom.X = BottomLeft.X * (1 - tx) + BottomRight.X * tx;
            bottom.Y = BottomLeft.Y * (1 - tx) + BottomRight.Y * tx;
            bottom.Z = BottomLeft.Z * (1 - tx) + BottomRight.Z * tx;

            result.X = top.X * (1 - ty) + bottom.X * ty;
            result.Y = top.Y * (1 - ty) + bottom.Y * ty;
            result.Z = top.Z * (1 - ty) + bottom.Z * ty;

            return(result);
        }