Computer Science Canada Triangle Maker |
Author: | uberwalla [ Sun Dec 17, 2006 10:42 pm ] | ||
Post subject: | Triangle Maker | ||
ok so i just felt like having something that made equalateral triangles easily. ive made this so far.
what i would like some help on is that i got it so that in many arrangements for the coordinates it makes it but a lot it doesn't. i was wondering if anyone could help me make it so it pretty much always makes one. Right now one that works is when u place 10,10,100,10. as i have made it i tried to take into count the angles to make it and thats why it was like x2- 45 to make that fill up to the 100. help greatly appreciated. thx. |
Author: | Clayton [ Sun Dec 17, 2006 11:05 pm ] |
Post subject: | |
use Draw.Polygon and some trig to get all of the sides equal sizes ![]() |
Author: | Piro24 [ Sun Dec 17, 2006 11:12 pm ] |
Post subject: | |
Well, the way I see it, it's kind of dumb to ask for the ending points, because you are going to be changing them anyways. So just ask for two points (x and y) and then automatically assign the 3rd co-ordinate to a place that would make the first to co-ordinates into an equilateral triangle. |
Author: | Clayton [ Sun Dec 17, 2006 11:25 pm ] |
Post subject: | |
ahh, but then which of the two points left available to make the triangle equilateral do you want? |
Author: | uberwalla [ Sun Dec 17, 2006 11:31 pm ] |
Post subject: | |
i have it set up with the 4 coordinates so that i can not only have it facing up. (meaning pointing to top of screen.) i want it so its at any angle at which the point points too ![]() |
Author: | CodeMonkey2000 [ Mon Dec 18, 2006 2:14 am ] |
Post subject: | |
you could use pythagoran theorum to find the distance between the first to points, then use that to figure out where your last point should be. i dont know much about trig so i dont know that solution. ( ![]() |
Author: | uberwalla [ Mon Dec 18, 2006 8:05 am ] |
Post subject: | |
good idea ill try it. and i think you should know some trig. my gr 9 class at school learned a bit. |
Author: | zylum [ Mon Dec 18, 2006 9:00 am ] | ||
Post subject: | |||
the best way i could think of is to inscribe a circle with the triangle. if you think of a circle inscribed with an equalateral triangle, you will notice they both share their centroid. also, from the center of the circle each of the triangles vertices are located at 120 degree increments around the circle (360 / number of sides). knowing all of that you can draw your triangle based on the circles center position and its radius. here's a more generalized function i had made earlier that you can play around with. it inscribes a circle with a proper polygon with a rotation of angle. with angle at 0 one of the vertices will be at the right side of the circle. angle will rotate the polygon counter-clockwise
|
Author: | CodeMonkey2000 [ Mon Dec 18, 2006 8:02 pm ] |
Post subject: | |
we barely did trig. its not enough to do something really cool. |