Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have 2 lines that i draw like this:

PointF PitCenter = new Point(150, 186);
PointF p = new PointF(PitCenter.X - 20, PitCenter.Y - 250);
PointF p2 = new PointF(PitCenter.X + 20, PitCenter.Y - 250);

DrawLine(PitCenter, new PointF(
    (p.Y - PitCenter.Y) * Math.Sin(Alpha * Math.PI / 180) + p.X),
    PitCenter.Y + (p.Y - PitCenter.Y) * Math.Cos(Alpha * Math.PI / 180));

DrawLine(PitCenter, new PointF(
    (p2.Y - PitCenter.Y) * Math.Sin(Alpha * Math.PI / 180) + p2.X),
    PitCenter.Y + (p2.Y - PitCenter.Y) * Math.Cos(Alpha * Math.PI / 180));

New X calculation: (p.Y - PitCenter.Y) * Math.Sin(Alpha * Math.PI / 180) + p.X)

New Y calculation: PitCenter.Y + (p.Y - PitCenter.Y) * Math.Cos(Alpha * Math.PI / 180)

Here are the lines when Alpha = 0;

enter image description here

And here are the lines after 90 degrees rotation..

enter image description here

As you see the lines somehow meets.. i really cant understand why.. Any ideas?

share|improve this question
add comment

1 Answer 1

Looks like you got the parentheses mangled in your line drawing commands -- the PointF constructor has only one argument and the DrawLinemethod has three; presumably that should be two and two? But that would lead to an error at compile time, so I presume you just didn't copy the code that you're actually using (which is a bad idea).

The reason the lines don't come out right is that you're applying the rotation to the $y$ coordinate but not to the $x$ coordinate. For instance, the first line drawing command should read

DrawLine(PitCenter, new PointF(
PitCenter.X +
(p.X - PitCenter.X) * Math.Cos(Alpha * Math.PI / 180) +
(p.Y - PitCenter.Y) * Math.Sin(Alpha * Math.PI / 180),
PitCenter.Y +
(p.Y - PitCenter.Y) * Math.Cos(Alpha * Math.PI / 180) -
(p.X - PitCenter.X) * Math.Sin(Alpha * Math.PI / 180)));
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.