Hi Everyone,

I am trying to creale an application which is supposed to display some line trace.What I have is the lenght of lines and the angle
(Azimut) degree of the Line for example 45 degree.
Can you please let me know how I can do this? I also have the Start point location.

Thanks for your time in Advanced

x1 = startx
y1 = starty
x2 = x1 + cos(angle) * length
y2 = y1 + sin(angle) * length

Regards,
Emil Olofsson

Hi again Emilo

I trired the method that you sujested byt It seems there is something wrong with angle! here is the code which I create

 double length = 350;
 double angle = 50;
 double x1 = 200;
 double y1 = 200;
 double x2 = x1 + (Math.Cos(angle) * length);
 double y2 = y1 + (Math.Sin(angle) * length);

 int intX1 = Convert.ToInt32(x1);
 int intY1 = Convert.ToInt32(y1);
 int intX2 = Convert.ToInt32(x2);
 int intY2 = Convert.ToInt32(y2);

 System.Drawing.Graphics graphicsObj;
 graphicsObj = this.CreateGraphics();
 Pen myPen = new Pen(System.Drawing.Color.Red, 5);
 graphicsObj.DrawLine(myPen, new Point(intX1, intY1),new Point(intX2, intY2));

Can you please take a look at code and let me know if this correct ot not?

Thanks for your time

Edited 4 Years Ago by Behseini

Hi!

Math.Sin and Math.Cos takes angles measured in radians and not degrees. Try this:

double angleRadians = (Math.PI / 180.0) * angle;

Then use angleRadians instead.

Regards,
Emil Olofsson

Comments
Quickly solved!
This question has already been answered. Start a new discussion instead.