Created
May 7, 2017 09:45
-
-
Save Frazi1/20ab7cc1e5b7edaac76f738776a305ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void DrawGeometry(StreamGeometryContext context) | |
{ | |
Point startPoint = new Point(CenterX, CenterY); | |
Point innerArcStartPoint = | |
Utils.CartesianCoordinate(RotationAngle, InnerRadius); | |
innerArcStartPoint.Offset(CenterX, CenterY); | |
Point innerArcEndPoint = | |
Utils.CartesianCoordinate(RotationAngle + WedgeAngle, InnerRadius); | |
innerArcEndPoint.Offset(CenterX, CenterY); | |
Point outerArcStartPoint = | |
Utils.CartesianCoordinate(RotationAngle, Radius); | |
outerArcStartPoint.Offset(CenterX, CenterY); | |
Point outerArcEndPoint = | |
Utils.CartesianCoordinate(RotationAngle + WedgeAngle, Radius); | |
outerArcEndPoint.Offset(CenterX, CenterY); | |
bool largeArc = WedgeAngle > 180.0; | |
Size outerArcSize = new Size(Radius, Radius); | |
Size innerArcSize = new Size(InnerRadius, InnerRadius); | |
context.BeginFigure(outerArcStartPoint, true, true); | |
context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true); | |
context.LineTo(innerArcEndPoint, true, true); | |
context.ArcTo(innerArcStartPoint, innerArcSize, 0, largeArc, SweepDirection.Counterclockwise, true, true); | |
context.Close(); | |
} | |
public static Point CartesianCoordinate(double angle, double radius) | |
{ | |
double angleRad = ToRadians(angle); | |
double x = radius * Math.Cos(angle); | |
double y = radius * Math.Sin(angle); | |
return new Point(x,y); | |
} | |
private static double ToRadians(double rotationAngleDegrees) | |
{ | |
return rotationAngleDegrees * Math.PI / 180; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment