This project is read-only.

Intersectionpoint(s) of Line and Arc

Apr 22, 2010 at 11:19 PM

Hi everyone,

while I was searching the web for this task I came across this project.

What I want is to find the Intersection point(s) of a linesegment and an arcsegment in Silverlight.

Trying the GetIntersectionOfEllipseAndLine(....) method in your Math Class I don't get the right points if semimajor and semiminor values are not the same, in other words if it's an ellipse.? Anyone having the same issue?

For my understanding I get the Center of my ArcSegment (which is the center of the two points describing the arc), then the semimajor and semiminor (which are the Size value's of the ArcSegment), the RotationAngle of the ArcSegment and finally the two Points describing my line. 

If semiminor and semimajor are forming a circle everything is fine.



Apr 23, 2010 at 1:04 PM

That sounds like some of the code I added.  I'll have some time later today to take a look.

Apr 27, 2010 at 1:45 AM


Sorry about the delay.  I'm not sure where the problem is but I suspect it has to do with the rotation angle of the arc.  The Arc class in LG does not use ArcSegment's RotationAngle.  All the algorithms are based on center, begin point, and end point.  You'll notice that the Angle property in ArcBase (Arc's parent class) returns zero.  Kirill set up the ArcBase and Arc class and could probably answer your question without much thought.

I'd also like to know what's going on and I've wanted a way to create elliptical arcs too.  So I'm going to try implementing it. I hope I'll have it uploaded tomorrow.  In the process we'll figure out what's going on - perhaps you have already figured it out.  I hope Kirill will also be okay with this added funtionality.


Apr 27, 2010 at 7:57 AM

I will be okay ;) Sorry folks, really busy these days.

Apr 27, 2010 at 7:21 PM


I just checked in my code that implements general elliptical arcs.  Perhaps one thing that was messing up your attempts is the fact that ArcSegment.RotationAngle needs to be the negated when used in the Math intersection methods.

I put the EllipseArc class in the Arc.cs file and the EllipseArcCreator in the ArcCreator.cs file.  I also exposed a lot of ellipse arc properties in the properties grid.


Apr 27, 2010 at 7:25 PM

Thanks David! I think what you're proposing with Arcs is great - please feel free to go ahead with your changes.


Apr 27, 2010 at 8:54 PM


figured out that this was not my real problem.

Ok, my arcSegment must always draw Circle's. For this reason I calculate the Arc's Width with the following formula:

arcXRadius = (4 * Math.Pow(height, 2) + Math.Pow(distanceArcPoints, 2)) / (8 * height);

so Arcs.Size = (arcXRadius,height)

But seems that the height is scaled down when drawn. I want to add a small Circle to the Arc's middle (highest point) so when you drag it it changes the arc Height but also changes the Width so it will remain a circle. 

Here's how I calculate the Circle's point:

Point middlePoint = GetMiddlePoint(arcPointA,arcPointB);
double arcYRadius = arcSegment.Size.Height;
            if (arcYRadius <= 0)
                return middlePoint;
            double angle = arcSegment.RotationAngle;

            Point ellinewPoint = new Point();
            ellinewPoint.X = Math.Cos((angle + 90) * Math.PI / 180) * arcYRadius + middlePoint.X;
            ellinewPoint.Y = Math.Sin((angle + 90) * Math.PI / 180) * arcYRadius + middlePoint.Y;

Until Arc's.Size.Height Property gets Closer to the Width my Circle is not at the right Point.

I'm sure this is not for this Discussion Forum but maybe someone can tell me what am I doing wrong.