Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: draw a triangle..  (Read 2145 times)

0 Members and 1 Guest are viewing this topic.

Kocoo

  • Newbie
  • *
  • Posts: 2
    • View Profile
draw a triangle..
« on: April 24, 2011, 08:41:47 pm »
Hello...

for a school project, i have to make a program that draws a triangle..
as input you insert the lenght of a,b and c sides..

I don't know to get the 3 corners out of the lenght of the sides...

Any help ?

Fred_FS

  • Newbie
  • *
  • Posts: 48
    • View Profile
draw a triangle..
« Reply #1 on: April 25, 2011, 12:20:54 am »
I would set point A to (0|0). Point B is set at B(c|0)(c is opposite of point C. a opposite of A aHence the line between A and B. Now you have to find C. C is the intersection of a circle around point A with radius b and a circle around point B with radius a. So I would just step through all the points of a circle around point A with radius b and would check, wether the distance between this new point and B equals to line a.

To find all these points on a circle I would use:
x = center_x + r * cos phi
y = center_y + r * sin phi

Kocoo

  • Newbie
  • *
  • Posts: 2
    • View Profile
draw a triangle..
« Reply #2 on: April 25, 2011, 10:05:00 am »
Ok thx..

Just, which points are center_x and center_y ?

Fred_FS

  • Newbie
  • *
  • Posts: 48
    • View Profile
draw a triangle..
« Reply #3 on: April 25, 2011, 07:47:55 pm »
Every circle has a center. So center_x is the x value of your center and center_y is your y value ;).
In your case it would be a circle around point A. So center_x is 0 and center_y is 0, too ;).