I am new to C#, porting some code over to TypeScript from C#. In the C# code, it says this:
public TilingConfig( int p, int q, int maxTiles ) : this()
{
SetupConfig( p, q, maxTiles );
}
public TilingConfig( int p, int q ) : this()
{
if( Geometry2D.GetGeometry( p, q ) != Geometry.Spherical )
throw new System.ArgumentException();
SetupConfig( p, q, PlatonicSolids.NumFacets( p, q ) );
}
private void SetupConfig( int p, int q, int maxTiles )
{
P = p;
Q = q;
m.Unity();
MaxTiles = maxTiles;
Shrink = 1.0;
}
public int P { get; set; }
public int Q { get; set; }
/// <summary>
/// The induced geometry.
/// </summary>
public Geometry Geometry { get { return Geometry2D.GetGeometry( this.P, this.Q ); } }
/// <summary>
/// A Mobius transformation to apply while creating the tiling.
/// </summary>
public Mobius M { get { return m; } set { m = value; } }
private Mobius m;
/// <summary>
/// The max number of tiles to include in the tiling.
/// </summary>
public int MaxTiles { get; set; }
/// <summary>
/// A shrinkage to apply to the drawn portion of a tile.
/// Default is 1.0 (no shrinkage).
/// </summary>
public double Shrink { get; set; }
/// <summary>
/// Returns a Mobius transform that can be used to create a dual {q,p} tiling.
/// This Mobius transform will center the tiling on a vertex.
/// </summary>
public Mobius VertexCenteredMobius()
{
return VertexCenteredMobius( this.P, this.Q );
}
public static Mobius VertexCenteredMobius( int p, int q )
{
double angle = Math.PI / q;
if( Utils.Even( q ) )
angle *= 2;
Vector3D offset = new Vector3D( -1 * Geometry2D.GetNormalizedCircumRadius( p, q ), 0, 0 );
offset.RotateXY( angle );
Mobius m = new Mobius();
m.Isometry( Geometry2D.GetGeometry( p, q ), angle, offset.ToComplex() );
return m;
}
/// <summary>
/// This Mobius transform will center the tiling on an edge.
/// </summary>
public Mobius EdgeMobius()
{
Geometry g = Geometry2D.GetGeometry( this.P, this.Q );
Polygon poly = new Polygon();
poly.CreateRegular( this.P, this.Q );
Segment seg = poly.Segments[0];
Vector3D offset = seg.Midpoint;
double angle = Math.PI / this.P;
offset.RotateXY( -angle );
Mobius m = new Mobius();
m.Isometry( g, -angle, -offset );
return m;
}
}
Specifically the line in SetupConfig
, which says:
m.Unity();
Where is that m
instantiated? Is it a default of some sort? If so, where is the default specified for Mobius
type? Here is the full source code.
CodePudding user response:
In this source code you can check that the Mobius is a struct. Struct can be define without constructor. Docs.