/// <summary> /// Hopf Link between two points on S^2. /// </summary> public static void HopfLink(StreamWriter sw, Vector3D s2_1, Vector3D s2_2, bool anti) { Vector3D[] circlePoints; string circleString; circlePoints = OneHopfCircleProjected(s2_1, anti); circleString = PovRay.EdgeSphereSweep(circlePoints, SizeFunc); sw.WriteLine(circleString); circlePoints = OneHopfCircleProjected(s2_2, anti); circleString = PovRay.EdgeSphereSweep(circlePoints, SizeFunc); sw.WriteLine(circleString); Mesh mesh = new Mesh(); Vector3D[] interpolated = S3.GeodesicPoints(s2_1, s2_2); for (int i = 0; i < interpolated.Length - 1; i++) { Vector3D v1 = interpolated[i]; Vector3D v2 = interpolated[i + 1]; Vector3D[] p1 = OneHopfCircleProjected(v1, anti); Vector3D[] p2 = OneHopfCircleProjected(v2, anti); for (int j = 0; j < p1.Length - 1; j++) { Mesh.Triangle t1 = new Mesh.Triangle(p1[j], p1[j + 1], p2[j]); Mesh.Triangle t2 = new Mesh.Triangle(p2[j], p1[j + 1], p2[j + 1]); mesh.Triangles.Add(t1); mesh.Triangles.Add(t2); } } PovRay.WriteMesh(sw, mesh, append: true); }
public static void HopfOrbit() { List <Vector3D> s2Points = new List <Vector3D>(); for (double theta = Math.PI * .1; theta <= Math.PI * .9; theta += Math.PI * .2) { for (double lon = -Math.PI; lon <= Math.PI; lon += Math.PI / 10) { s2Points.Add(SphericalCoords.SphericalToCartesian(new Vector3D(1.0, theta, lon))); } } using (StreamWriter sw = File.CreateText(@".\out.pov")) { System.Func <Vector3D, Sphere> sizeFunc = v => new Sphere() { Center = v, Radius = 0.01 }; foreach (Vector3D s2Point in s2Points) { Vector3D[] circlePoints = OneHopfCircle(s2Point); //for( int i = 0; i < circlePoints.Length; i++ ) // circlePoints[i] = circlePoints[i].ProjectTo3DSafe( 1.0 ); // Note: effectively orthogonal projects here because EdgeSphereSweep doesn't write W coord. string circleString = PovRay.EdgeSphereSweep(circlePoints, sizeFunc); sw.WriteLine(circleString); } } }
public void Gen(int p, int q, int r) { Geometry g = Util.GetGeometry(p, q, r); if (g != Geometry.Spherical) { throw new System.Exception("Point group code only for spherical geometry."); } Simplex simplex = new Simplex(); simplex.Facets = SimplexCalcs.Mirrors(p, q, r); Vector3D cen = new Vector3D(); Vector3D faceCenter = SimplexCalcs.FaceCenterSpherical(p, q, r); Vector3D edgeMid = SimplexCalcs.EdgeMidpointSpherical(p, q, r); Vector3D vertex = SimplexCalcs.VertexSpherical(p, q, r); List <Vector3D> startingPoles = new List <Vector3D>(); startingPoles.Add(Sterographic.S3toR3(GreatSphere.FromSphere(simplex.Facets[0]).Pole)); GreatSphere[] spheres = CalcSpheres(simplex.Facets, startingPoles.ToArray()); string filename = "point_group.pov"; using (StreamWriter sw = File.CreateText(filename)) { //foreach( var greatSphere in spheres ) //sw.WriteLine( PovRay.Sphere( greatSphere.ToSphere() ) ); } /* * List<H3.Cell.Edge> startingEdges = new List<H3.Cell.Edge>(); * startingEdges.Add( new H3.Cell.Edge( cen, faceCenter ) ); * H3.Cell.Edge[] edges = Recurse.CalcEdges( simplex.Facets, startingEdges.ToArray(), new Recurse.Settings() { G = Geometry.Spherical, Threshold = 0.001 } ); * //edges = edges.Where( e => !( Infinity.IsInfinite( e.Start ) || Infinity.IsInfinite( e.End ) ) ).ToArray(); * * PovRay.WriteEdges( new PovRay.Parameters() { AngularThickness = 0.01 }, Geometry.Spherical, edges, filename, append: true ); */ double minRad = 0; double thick = 0.005; System.Func <Vector3D, Sphere> sizeFunc = v => { Vector3D c; double rad; H3Models.Ball.DupinCyclideSphere(v, thick / 2, g, out c, out rad); return(new Sphere() { Center = c, Radius = Math.Max(rad, minRad) }); }; // All geodesics List <Circle3D> startingCircles = new List <Circle3D>(); startingCircles.Add(GeodesicFrom2Points(cen, edgeMid)); Circle3D[] geodesics = CalcGeodesics(simplex.Facets, startingCircles.ToArray()); Vector3D color = new Vector3D(0, 0, 1); using (StreamWriter sw = File.CreateText(filename)) { Shapeways shapeways = new Shapeways(); foreach (Circle3D geodesic in geodesics) { Vector3D[] points; if (Infinity.IsInfinite(geodesic.Radius)) { double cutoff = 15; Segment seg = Segment.Line(geodesic.Normal * cutoff, geodesic.Normal * -cutoff); points = seg.Subdivide(42); } else { List <Vector3D> tempPoints = geodesic.Subdivide(150).ToList(); tempPoints.Add(tempPoints[0]); tempPoints.Add(tempPoints[1]); points = tempPoints.ToArray(); } List <Vector3D> ePoints = new List <Vector3D>(); List <double> eRadii = new List <double>(); foreach (Vector3D pNE in points) { Sphere sphere = sizeFunc(pNE); ePoints.Add(sphere.Center); eRadii.Add(sphere.Radius); } shapeways.AddCurve(ePoints.ToArray(), eRadii.ToArray()); sw.WriteLine(PovRay.EdgeSphereSweep(points, sizeFunc, color)); } STL.SaveMeshToSTL(shapeways.Mesh, "533.stl"); } }