///<summary> /// Generates the geometry for the sine star ///</summary> /// <returns>The geometry representing the sine star</returns> public IGeometry CreateSineStar() { Envelope env = Envelope; double radius = env.Width / 2.0; double armRatio = ArmLengthRatio; if (armRatio < 0.0) { armRatio = 0.0; } if (armRatio > 1.0) { armRatio = 1.0; } double armMaxLen = armRatio * radius; double insideRadius = (1 - armRatio) * radius; double centreX = env.MinX + radius; double centreY = env.MinY + radius; Coordinate[] pts = new Coordinate[NumPoints + 1]; int iPt = 0; for (int i = 0; i < NumPoints; i++) { // the fraction of the way thru the current arm - in [0,1] double ptArcFrac = (i / (double)NumPoints) * NumArms; double armAngFrac = ptArcFrac - Math.Floor(ptArcFrac); // the angle for the current arm - in [0,2Pi] // (each arm is a complete sine wave cycle) double armAng = 2 * Math.PI * armAngFrac; // the current length of the arm double armLenFrac = (Math.Cos(armAng) + 1.0) / 2.0; // the current radius of the curve (core + arm) double curveRadius = insideRadius + armMaxLen * armLenFrac; // the current angle of the curve double ang = i * (2 * Math.PI / NumPoints); double x = curveRadius * Math.Cos(ang) + centreX; double y = curveRadius * Math.Sin(ang) + centreY; pts[iPt++] = CreateCoord(x, y); } pts[iPt] = new Coordinate(pts[0]); ILinearRing ring = GeomFact.CreateLinearRing(pts); IPolygon poly = GeomFact.CreatePolygon(ring); return(poly); }
public void run() { var env = new Envelope(0, 100, 0, 100); var comb1 = Comb(env, SIZE); var centre = env.Centre; var trans = AffineTransformation.RotationInstance(0.5 * Math.PI, centre.X, centre.Y); var comb2 = (IPolygon)trans.Transform(comb1); var mp = GeomFact.CreateMultiPolygon(new[] { comb1, comb2 }); //System.out.println(mp); var isValid = mp.IsValid; Debug.WriteLine("Is Valid = " + isValid); }