Last post Apr 29, 2008 08:05 AM by jagguy

• jagguy

Member

2 Points

165 Posts

### draw triangle

Hi,
I want to draw a triangle with GDI system.drawing. Now What i want to do is the user to enter in 2 angles . To keep it simple say 100 is line distance in pixels for 1st line.

if user enters in 30 and 80 the 3rd angle can be worked out to 70. It is confusing on how to construct a triangle to these angle measurements (not simple  right angles). I dont care about side lengths for the finished triangle just the angles..

I know I can rotate a point around the origin or point.
with x'= x cos(theta) +ysin(theta)
y' =y cos(theta) -xsin(theta)

i am confused as to how to work this out with math function in asp.net.

it is a scalene triangle

• jagguy

Member

2 Points

165 Posts

### Re: draw triangle

ok i can work out the mathematics but I cant convert the ytiangle to X Y coordinates.

I have a triangle with angles 10,10,160 and distances 300,153.5,153.3

How do i convert this triangle to X,Y points starting at 0,0 and next point is 0,300 so what ais the next point?

I tried the below but this fails as it gives (127.8,82)  which makes the triangle have a different side length than 153.3.

Dim x As Single = Math.Abs((b * CSng(Math.Cos(alpha)))) + OFFSET
Dim y As Single = Math.Abs((b * CSng(Math.Sin(alpha)))) + OFFSET