private static Polygon[] GenerateStarting(int X, int Y, int Z) { Geometry g = Geometry.Euclidean; // First generate the 3 starting polygons. Polygon poly1 = Polygon.CreateEuclidean(X); Polygon poly2 = Polygon.CreateEuclidean(Y); Polygon poly3 = Polygon.CreateEuclidean(Z); //double a1 = Polygon.InteriorAngle( X ); //double a2 = Polygon.InteriorAngle( Y ); //double a3 = Polygon.InteriorAngle( Z ); // Normalize polygons to have edge length = 1. poly1.Scale(1.0 / poly1.Segments.First().Length); poly2.Scale(1.0 / poly2.Segments.First().Length); poly3.Scale(1.0 / poly3.Segments.First().Length); // Transform them so their first vertex is at the origin, // And poly1/poly2 share an edge, as well as poly1/poly3 // poly2 and poly3 may or may not share an edge. Complex origin = new Complex(0, 0); poly1.Transform(Mobius.CreateFromIsometry(g, 0, -poly1.Vertices.First())); poly2.Transform(Mobius.CreateFromIsometry(g, 0, -poly2.Vertices.First())); poly3.Transform(Mobius.CreateFromIsometry(g, 0, -poly3.Vertices.First())); poly2.Transform(Mobius.CreateFromIsometry(g, poly1.Vertices.Last().AngleTo(poly2.Vertices.Skip(1).First()), origin)); poly3.Transform(Mobius.CreateFromIsometry(g, -poly1.Vertices.Last().AngleTo(poly3.Vertices.Skip(1).First()), origin)); // Now connect poly2/poly3. ConnectPolys(poly1, poly2, poly3); return(new Polygon[] { poly1, poly2, poly3 }); }
public void GenerateInternal(TilingConfig config, Polytope.Projection projection = Polytope.Projection.FaceCentered) { this.TilingConfig = config; // Create a base tile. Tile tile = CreateBaseTile(config); // Handle edge/vertex centered projections. if (projection == Polytope.Projection.VertexCentered) { Mobius mobius = config.VertexCenteredMobius(); tile.Transform(mobius); } else if (projection == Polytope.Projection.EdgeCentered) { Mobius mobius = config.EdgeMobius(); tile.Transform(mobius); } TransformAndAdd(tile); List <Tile> tiles = new List <Tile>(); tiles.Add(tile); Dictionary <Vector3D, bool> completed = new Dictionary <Vector3D, bool>(); completed[tile.Boundary.Center] = true; ReflectRecursive(tiles, completed); FillOutIsometries(tile, m_tiles, config.Geometry); FillOutIncidences(); }
/// <summary> /// Same as above, but works with all geometries. /// </summary> public static Circle EquidistantOffset(Geometry g, Segment seg, double offset) { Mobius m = new Mobius(); Vector3D direction; if (seg.Type == SegmentType.Line) { direction = seg.P2 - seg.P1; direction.RotateXY(Math.PI / 2); } else { direction = seg.Circle.Center; } direction.Normalize(); m.Isometry(g, 0, direction * offset); // Transform 3 points on segment. Vector3D p1 = m.Apply(seg.P1); Vector3D p2 = m.Apply(seg.Midpoint); Vector3D p3 = m.Apply(seg.P2); return(new Circle(p1, p2, p3)); }
public async void GetsTransferInfoAsync() { Guid tokenAddressTransferUID = Guid.NewGuid(); Guid UID = Guid.NewGuid(); TransferStatus status = TransferStatus.Complete; string transactionHash = "asdujasd32409892345893485"; var testHttpClient = StartTestHostWithFixedResponse(GetPath("tokens", "transfer/info"), 200, new TransferInfoResponse { UID = UID, Status = status, TransactionHash = transactionHash }); var mobius = new Mobius(testHttpClient, GetConnectionInfo()); var response = await mobius.Tokens.GetTransferInfoAsync(new TransferInfoRequest { TokenAddressTransferUID = tokenAddressTransferUID }); Assert.NotNull(response); Assert.Equal(UID, response.UID); Assert.Equal(status, response.Status); Assert.Equal(transactionHash, response.TransactionHash); }
public static Vector3D LoxodromicToIsometric(Vector3D v, int p, int m, int n) { Mobius mob = Mobius.CreateFromIsometry(Geometry.Spherical, 0, new System.Numerics.Complex(1, 0)); v = mob.Apply(v); return(SpiralToIsometric(v, p, m, n)); }
// Gets the distance between two points. private double Dist(Vector3D p1, Vector3D p2) { switch (this.Metric) { case Metric.Spherical: { // ZZZ - Is it too expensive to build up a mobius every time? // I wonder if there is a better way. Mobius m = new Mobius(); m.Isometry(Geometry.Spherical, 0, -p1); Vector3D temp = m.Apply(p2); return(Spherical2D.e2sNorm(temp.Abs())); } case Metric.Euclidean: { return((p2 - p1).Abs()); } case Metric.Hyperbolic: { // ZZZ - Is it too expensive to build up a mobius every time? // I wonder if there is a better way. Mobius m = new Mobius(); m.Isometry(Geometry.Hyperbolic, 0, -p1); Vector3D temp = m.Apply(p2); return(DonHatch.e2hNorm(temp.Abs())); } } throw new System.NotImplementedException(); }
public int Closest(Vector3D p) { // Needs to be non-euclidean calc, // Moving the hex to the center will make that be the case. Mobius m = MobiusToCenter; Polygon poly = Hexagon.Clone(); poly.Transform(m); p = m.Apply(p); double d1 = poly.Segments[1].Midpoint.Dist(p); double d2 = poly.Segments[3].Midpoint.Dist(p); double d3 = poly.Segments[5].Midpoint.Dist(p); double min = Math.Min(d1, Math.Min(d2, d3)); if (min == d1) { return(4); } if (min == d2) { return(0); } if (min == d3) { return(2); } return(-1); }
public void Transform(Mobius m) { Hexagon.Transform(m); TestCircle.Transform(m); CircumCircle.Transform(m); Isometry *= new Isometry(m, null); }
/// <summary> /// Subdivides a segment from p1->p2 with the two endpoints not on the origin, in the respective geometry. /// </summary> public static Vector3D[] SubdivideSegmentInGeometry(Vector3D p1, Vector3D p2, int divisions, Geometry g) { // Handle this specially, so we can keep things 3D if needed. if (g == Geometry.Euclidean) { Segment seg = Segment.Line(p1, p2); return(seg.Subdivide(divisions)); } Mobius p1ToOrigin = new Mobius(); p1ToOrigin.Isometry(g, 0, -p1); Mobius inverse = p1ToOrigin.Inverse(); Vector3D newP2 = p1ToOrigin.Apply(p2); Segment radial = Segment.Line(new Vector3D(), newP2); Vector3D[] temp = SubdivideRadialInGeometry(radial, divisions, g); List <Vector3D> result = new List <Vector3D>(); foreach (Vector3D v in temp) { result.Add(inverse.Apply(v)); } return(result.ToArray()); }
private static Isometry SetupIsometry(Cell clickedCell, Vector3D clickedPoint, Puzzle puzzle) { int p = puzzle.Config.P; Geometry g = puzzle.Config.Geometry; Isometry cellIsometry = clickedCell.Isometry.Clone(); // Take out reflections. // ZZZ - Figuring out how to deal with these reflected isometries was a bit painful to figure out. // I wish I had just taken more care to not have any cell isometries with reflections. // Maybe I can rework that to be different at some point. if (cellIsometry.Reflection != null) { cellIsometry = Isometry.ReflectX() * cellIsometry; } // Round to nearest vertex. Vector3D centered = cellIsometry.Apply(clickedPoint); double angle = Euclidean2D.AngleToCounterClock(centered, new Vector3D(1, 0)); double angleFromZeroToP = p * angle / (2 * Math.PI); angleFromZeroToP = Math.Round(angleFromZeroToP, 0); if (p == (int)angleFromZeroToP) { angleFromZeroToP = 0; } angle = 2 * Math.PI * angleFromZeroToP / p; // This will take vertex to canonical position. Mobius rotation = new Mobius(); rotation.Isometry(g, angle, new Complex()); Isometry rotIsometry = new Isometry(rotation, null); return(rotIsometry * cellIsometry); }
// Start is called before the first frame update void Start() { CoinObject co = createCoin(new Vector3(0, 1, 0)); co.setTree(null, 1); Mobius mob = new Mobius(); int sides = numberOfSides; int steps = maximumSteps - 1; if (steps <= 0) { return; } createSubtree(sides, steps, mob, co); int count = 0; for (int i = 0; i < sides - 1; i++) { mob.compose(new Mobius(Math.PI * 2 / sides)); count += createSubtree(sides, steps, mob, null); } transform.GetComponent <HyperbolicPlane>().setTree(count); }
// Rotates a dodec about a vertex or edge to get a dual dodec. private static Dodec GetDual(Dodec dodec, Vector3D rotationPoint) { //double rot = System.Math.PI / 2; // Edge-centered double rot = 4 * (-Math.Atan((2 + Math.Sqrt(5) - 2 * Math.Sqrt(3 + Math.Sqrt(5))) / Math.Sqrt(3))); // Vertex-centered Mobius m = new Mobius(); if (Infinity.IsInfinite(rotationPoint)) { m.Elliptic(Geometry.Spherical, new Vector3D(), -rot); } else { m.Elliptic(Geometry.Spherical, rotationPoint, rot); } Dodec dual = new Dodec(); foreach (Vector3D v in dodec.Verts) { Vector3D rotated = m.ApplyInfiniteSafe(v); dual.Verts.Add(rotated); } foreach (Vector3D v in dodec.Midpoints) { Vector3D rotated = m.ApplyInfiniteSafe(v); dual.Midpoints.Add(rotated); } return(dual); }
private static Vector3D DiskToUpper(Vector3D input) { Mobius m = new Mobius(); m.UpperHalfPlane(); return(m.Apply(input)); }
private int createSubtree(int sides, int steps, Mobius root, CoinObject parent) { int count = 0; Mobius mob = new Mobius(root); mob.compose(new Mobius(0, Math.Cos(Math.PI / sides), false)); CoinObject co = createCoin(mob.apply(new Vector3(0, 1, 0), true)); co.setTree(parent, sides - 1); if (parent == null) { co = null; count++; } steps--; if (steps <= 0) { if (parent != null) { co.activate(); } return(count); } mob.compose(new Mobius(Math.PI)); for (int i = 0; i < sides - 1; i++) { mob.compose(new Mobius(Mathf.PI * 2 / sides)); count += createSubtree(sides, steps, mob, co); } return(count); }
private Vector3D ApplyTransformationToSphere(Vector3D v, double t) { v = H3Models.BallToUHS(v); // 437 (hyperbolic) //v *= Math.Pow( 4.259171776329806, t*10-5 ); // 36i (parabolic) //v += new Vector3D( Math.Cos( Math.PI / 6 ), Math.Sin( Math.PI / 6 ) ) * t; // iii (loxodromic) //Complex c = v.ToComplex(); //double x = Math.Sqrt( 2 ) - 1; //Mobius m = new Mobius( new Complex( x, 0 ), Complex.One, new Complex( -x, 0 ) ); // 12,12,12 loxodromic //m = new Mobius( new Complex( 0, 1 ), Complex.One, new Complex( 0, -1 ) ); /* * c = m.Apply( c ); * c *= Complex.Exp( new Complex( 2.5, 4 * Math.PI ) * t ); * c = m.Inverse().Apply( c ); * v = Vector3D.FromComplex( c ); */ // Center cell head in KolorEyes. Mobius m = new Mobius(); m.UpperHalfPlane(); v = m.Inverse().Apply(v); return(H3Models.UHSToBall(v)); }
/// <summary> /// This needs to be called after the model is set. /// </summary> internal static Mobius RandomMobius(Tiler.Settings settings, Random rand) { Geometry g = settings.Geometry; // Pick a random point to move to origin. // Could be cool to make the geometry arbitrary here (i.e. a spherical transformation applied to a euclidean tiling looks sweet). Mobius m = new Mobius(); Complex c = new Complex(rand.NextDouble() / 2, rand.NextDouble() / 2); double a = rand.NextDouble() * Math.PI; if (g == Geometry.Euclidean) { if (settings.EuclideanModel == EuclideanModel.Isometric || settings.EuclideanModel == EuclideanModel.Loxodromic) { // I don't really like how the rotations look in the plane. // For Loxodromic, things won't line up if we allow this. a = 0; } else if (settings.EuclideanModel == EuclideanModel.Conformal) { g = Geometry.Spherical; c = new Complex(rand.NextDouble() * 4, rand.NextDouble() * 4); } } m.Isometry(g, a, c); return(m); }
/// <summary> /// Setup a circle we'll use to color neighbors. /// </summary> private void SetupNeighborCircle(Tile templateTriangle) { Polygon poly = m_tiles.First().Boundary; // Tetrahedral tiling. CircleNE circ = new CircleNE(); circ.Radius = m_shrink; circ.Reflect(poly.Segments[2]); circ.Reflect(templateTriangle.Boundary.Segments[1]); Mobius m = new Mobius(); m.Isometry(Geometry.Spherical, 0, -circ.CenterNE); circ.Transform(m); m_neighborCircle = new CircleNE(); m_neighborCircle.Radius = 1.0 / circ.Radius; m_originalNeighborCircle = m_neighborCircle.Clone(); System.Func <Vector3D, Vector3D> pointTransform = v => { v *= m_neighborCircle.Radius; v = new Vector3D(v.Y, v.X); v.RotateXY(-Math.PI / 2); return(v); }; m_neighborToStandardDisk = CalcMobius(pointTransform); }
public async void RegistersTokenAsync() { Guid UID = Guid.NewGuid(); const TokenType tokenType = TokenType.Stellar; const string name = @"Augur"; const string symbol = @"REP"; const string issuer = @"0xE94327D07Fc17907b4DB788E5aDf2ed424adDff6"; var testHttpClient = StartTestHostWithFixedResponse(GetPath("tokens", "register"), 200, new RegisterTokenResponse { UID = UID, TokenType = tokenType, Name = name, Symbol = symbol, Issuer = issuer }); var mobius = new Mobius(testHttpClient, GetConnectionInfo()); var response = await mobius.Tokens.RegisterTokenAsync(new RegisterTokenRequest { TokenType = tokenType, Issuer = issuer, Name = name, Symbol = symbol }); Assert.NotNull(response); Assert.Equal(UID, response.UID); Assert.Equal(tokenType, response.TokenType); Assert.Equal(name, response.Name); Assert.Equal(symbol, response.Symbol); Assert.Equal(issuer, response.Issuer); }
void PolarDemo(double time) { // CircLine inversionCircle = Circle.Create(new Complex(-1, -0.5), 1); CircLine inversionCircle = Circle.Create(new Complex(0, 0), 1); Mobius inversion = inversionCircle.AsInversion; inversionCircle.DrawGL(Color4.Gray); int circleCount = 6; Complex center = Complex.CreatePolar(0.3, time); for (int i = 0; i < circleCount; i++) { CircLine radialLine = Line.Create(center, Math.PI * i / circleCount); radialLine.DrawGL(Color4.Green); CircLine radialLineImage = inversion * radialLine.Conjugate; radialLineImage.DrawGL(Color4.GreenYellow); CircLine radialLineBack = inversion * radialLineImage.Conjugate; radialLineBack.DrawGL(Color4.Aqua); //CircLine circumferencialLine = Circle.Create(center, (double) (i + 1) / circleCount); //circumferencialLine.DrawGL(Color4.DarkRed); //CircLine circumferencialLineImage = inversion * circumferencialLine.Conjugate; //circumferencialLineImage.DrawGL(Color4.Red); } }
public static void Cell633() { TilingConfig config = new TilingConfig(6, 3, maxTiles: 20000); Tiling tiling = new Tiling(); tiling.GenerateInternal(config, Polytope.Projection.VertexCentered); double edgeLength = Honeycomb.EdgeLength(6, 3, 3); double z = 0.25; double offset = H3Models.UHS.ToEHorizontal(edgeLength, z); double scale = offset / tiling.Tiles.First().Boundary.Segments.First().Length; foreach (Tile tile in tiling.Tiles) { tile.Transform(Mobius.Scale(scale)); } Vector3D dummy; double radius; H3Models.UHS.Geodesic(new Vector3D(0, 0, z), new Vector3D(scale, 0, z), out dummy, out radius); Vector3D midradius = H3Models.UHSToBall(new Vector3D(0, 0, radius)); double temp = midradius.Z; double temp2 = (1 - temp) / 2; double temp3 = temp + temp2; double temp4 = temp3; Vector3D circumradius = H3Models.UHSToBall(new Vector3D(0, 0, z)); temp = circumradius.Z; temp2 = (1 - temp) / 2; temp3 = temp + temp2; temp4 = temp3; // Checking /* * Vector3D test = new Vector3D( offset, 0, z ); * test = H3Models.UHSToBall( test ); * double edgeLength2 = DonHatch.e2hNorm( test.Abs() ); * edgeLength2 += 0; */ HashSet <H3.Cell.Edge> edges = new HashSet <H3.Cell.Edge>(); foreach (Tile tile in tiling.Tiles) { foreach (Segment seg in tile.Boundary.Segments) { H3.Cell.Edge edge = new H3.Cell.Edge( H3Models.UHSToBall(seg.P1 + new Vector3D(0, 0, z)), H3Models.UHSToBall(seg.P2 + new Vector3D(0, 0, z))); edges.Add(edge); } } PovRay.WriteH3Edges(new PovRay.Parameters(), edges.ToArray(), "edges.pov"); }
/// <summary> /// initialRot is used to take a particular point to infinity. When 0, this point is (0,1) in the ball. /// off is used to do the limit rotation by doing a tranlation in the UHP. /// </summary> static public Mobius LimitRot(Tiler.Settings settings, double initialRot, double off) { Mobius mRot = new Mobius(), mOff = new Mobius(); mRot.Isometry(Geometry.Euclidean, initialRot, new Complex()); mOff.Isometry(Geometry.Euclidean, 0, new Complex(off, 0)); return(mRot.Inverse() * HyperbolicModels.UpperInv * mOff * HyperbolicModels.Upper * mRot); }
/// <summary> /// A Mobius that will put our simplex into a face centered orientation. /// Meant to be used with H3Models.TransformInBall2 or H3Models.TransformHelper /// </summary> internal static Mobius FCOrientMobius(Sphere cellSphereInBall) { Mobius m = new Mobius(); double d = cellSphereInBall.Center.Abs() - cellSphereInBall.Radius; m.Isometry(Geometry.Hyperbolic, 0, new Vector3D(0, d)); return(m); }
// Start is called before the first frame update void Start() { mobius = new Mobius(); camera = player.Find("SteamVRObjects").Find("VRCamera"); started = false; oldChildCount = 0; timer = -1; }
static public Mobius RotAboutPoint(Geometry g, Vector3D p, double rot) { Mobius m1 = new Mobius(), m2 = new Mobius(); m1.Isometry(g, 0, p); m2.Isometry(g, rot, new Complex()); return(m1 * m2 * m1.Inverse()); }
/// <summary> /// Apply a Mobius transform to us. /// </summary> public void Transform(Mobius m) { foreach (Segment s in this.Segments) { s.Transform(m); } Center = m.Apply(Center); }
private static Mobius RotMobius(Vector3D vertex0) { // A third rotation about the vertex. Mobius m = new Mobius(); m.Elliptic(Geometry.Hyperbolic, vertex0, 2 * Math.PI / 3); return(m); }
public void Transform(Mobius m) { Boundary.Transform(m); foreach (Sticker s in Stickers) { s.Poly.Transform(m); } VertexCircle.Transform(m); }
/// <summary> /// Helper to do a geodesic pan. /// </summary> private void GeodesicPan(Vector3D p1, Vector3D p2) { Mobius pan = new Mobius(); Isometry inverse = m_isometry.Inverse(); p1 = inverse.Apply(p1); p2 = inverse.Apply(p2); pan.Geodesic(m_geometry, p1, p2); m_isometry.Mobius *= pan; }
static void CreateAddress() { var mobius = new Mobius(GetConnectionDetails()); var response = mobius.Tokens.CreateAddress(new CreateAddressRequest { TokenUID = Guid.Parse("5ab77196-7fe1-5463-929a-ad33ffa430c9") }); Console.WriteLine(response); }
static void GetTransferInfo() { var mobius = new Mobius(GetConnectionDetails()); var response = mobius.Tokens.GetTransferInfo(new TransferInfoRequest { TokenAddressTransferUID = Guid.Parse("f9d3665d-fe72-49ec-3434-c2c0bfd1c57f") }); Console.WriteLine(response); }