Skip to content
Advertisement

Is there a way to get and save an angle of a turtle for later?

I’m making a program where the user can click on the screen 3 times and it makes a triangle. It will then find the middle points of those 3 lines. Next, I want it to draw 3 lines perpendicular to each of the lines that make up the triangle (through the middle points).

I’m stuck at drawing the perpendicular lines. I wanted to try to save (like you save a position or coordinates) the angles that the turtle bob (the one that connects the lines of the triangle) makes on each line, and then put the middle line turtles (l1, l2, l3) tilt in that angle. It would then make it go right and left and draw the line. I’m sorry if this is unclear, but I can’t really think of another way to explain it. This is my code:

JavaScript

If I need to explain more about what I exactly mean, please say so!

Advertisement

Answer

After putting your mid-point turtles in their spot, you can aim them towards the next point on the triangle.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement