ProjectToSurface() public method

Radially project a point onto our surface.
public ProjectToSurface ( Vector3D p ) : Vector3D
p Vector3D
return Vector3D
Exemplo n.º 1
0
        /// <summary>
        /// Calculates the point of our simplex that is at the middle of an edge.
        /// </summary>
        private static Vector3D MidEdgePointBall(int p, int q, int r)
        {
            // We need the mid-radius, but we have to do the calculation
            // with our Euclidean simplex mirrors (to avoid infinities that happen in the formulas).
            Circle3D edge = HoneycombEdgeUHS(p, q, r);

            if (edge.Radius == 0)
            {
                return(edge.Center);
            }

            Geometry cellGeometry = Geometry2D.GetGeometry(p, q);

            switch (cellGeometry)
            {
            case Geometry.Spherical:
            {
                Sphere sphereInBall = H3Models.UHSToBall(new Sphere()
                    {
                        Center = edge.Center, Radius = edge.Radius
                    });
                Vector3D mid = sphereInBall.ProjectToSurface(new Vector3D());                           // Project origin to sphere.
                return(mid);
            }

            case Geometry.Euclidean:
            {
                Vector3D mid = H3Models.UHSToBall(edge.Center + new Vector3D(0, 0, edge.Radius));
                return(mid);
            }

            case Geometry.Hyperbolic:
            {
                throw new System.NotImplementedException();
            }
            }

            throw new System.ArgumentException();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Given a geodesic sphere, find the point closest to the origin.
 /// </summary>
 public static Vector3D ClosestToOrigin( Sphere s )
 {
     return s.ProjectToSurface( new Vector3D() );
 }