Drawing Right Angled Triangles
I am basically looking for a way to animate a right angle triangle.
The right angle triangle would be placed within a panel in a windows forum. The base angle would be changed to a degree entered by the user in a textbox(so it would be less than 90 degrees), the base length however should not change. please view the diagram below
i would thinking a good way change the drawing would be to run a timer with a interval of 5 milliseconds uf the angle has number entered in the textbox has changed a new one would be redrawn.
i am open to any suggestions tho
There's no need to use a Timer. You would either require the user to click a Button to redraw the triangle or else simply handle the TextChanged event of the TextBox. That said, it would be more appropriate to use a NumericUpDown than a TextBox. That will ensure only numbers can be entered and it also allows you to specify a valid range. Do you know how to do the drawing using GDI+? I'd recommend a PictureBox as the canvas rather than a Panel. A Panel will work but a PictureBox is already optimised for graphics.
Thanks for the idea! however im still not certain how to go about coding the drawing of the right angle triangle
Originally Posted by jmcilhinney
You already know the two end points of the horizontal and you know the angle to the left. Some simple trigonometry gives you the other apex. Three calls to DrawLine using those three Points and you're done. Note that trig functions reside in the Math class.