Exemplo n.º 1
0
        public void SubDivide(List <Triangle> triList, List <PositionTexture> vertexList)
        {
            Vector3d a1 = Vector3d.Lerp(vertexList[B].Position, vertexList[C].Position, .5f);
            Vector3d b1 = Vector3d.Lerp(vertexList[C].Position, vertexList[A].Position, .5f);
            Vector3d c1 = Vector3d.Lerp(vertexList[A].Position, vertexList[B].Position, .5f);

            Vector2d a1uv = Vector2d.Lerp(new Vector2d(vertexList[B].Tu, vertexList[B].Tv), new Vector2d(vertexList[C].Tu, vertexList[C].Tv), .5);
            Vector2d b1uv = Vector2d.Lerp(new Vector2d(vertexList[C].Tu, vertexList[C].Tv), new Vector2d(vertexList[A].Tu, vertexList[A].Tv), .5);
            Vector2d c1uv = Vector2d.Lerp(new Vector2d(vertexList[A].Tu, vertexList[A].Tv), new Vector2d(vertexList[B].Tu, vertexList[B].Tv), .5);

            a1.Normalize();
            b1.Normalize();
            c1.Normalize();

            int aIndex = vertexList.Count;
            int bIndex = vertexList.Count + 1;
            int cIndex = vertexList.Count + 2;

            vertexList.Add(new PositionTexture(a1, a1uv.X, a1uv.Y));
            vertexList.Add(new PositionTexture(b1, b1uv.X, b1uv.Y));
            vertexList.Add(new PositionTexture(c1, c1uv.X, c1uv.Y));

            triList.Add(new Triangle(A, cIndex, bIndex));
            triList.Add(new Triangle(B, aIndex, cIndex));
            triList.Add(new Triangle(C, bIndex, aIndex));
            triList.Add(new Triangle(aIndex, bIndex, cIndex));
        }
Exemplo n.º 2
0
        public Vector2d PointToRaDec(Vector2d point) // point is between 0 and 1 inclusive
        {
            int indexX = (int)(point.X / subDivSize);
            int indexY = (int)(point.Y / subDivSize);

            if (indexX > ((int)Math.Pow(2, subDivisions) - 1))
            {
                indexX = ((int)Math.Pow(2, subDivisions) - 1);
            }
            if (indexY > ((int)Math.Pow(2, subDivisions) - 1))
            {
                indexY = ((int)Math.Pow(2, subDivisions) - 1);
            }
            double xDist = (point.X - ((double)indexX * subDivSize)) / subDivSize;
            double yDist = (point.Y - ((double)indexY * subDivSize)) / subDivSize;

            Vector2d interpolatedTop    = Vector2d.Lerp(raDecMap[indexX, indexY], raDecMap[indexX + 1, indexY], xDist);
            Vector2d interpolatedBottom = Vector2d.Lerp(raDecMap[indexX, indexY + 1], raDecMap[indexX + 1, indexY + 1], xDist);
            Vector2d result             = Vector2d.Lerp(interpolatedTop, interpolatedBottom, yDist);


            return(result);
        }