0

I am trying to write a small drawing program with Livecode, that will show the length of the drawn line over the line so it is available for editing, I also need to display the angles of the polygon for editing. The user should be able to select one section of the polygon by clicking on the dimension. This will load the length of the line into the field on the right for editing. Once the correct number is entered the drawing will redraw itself. (I can probably figure this part out using the "points" of the polygon) I have included a screen shot of what the program should look like. I was hoping that it would display these figures as the image was being drawn by the user. I am sorry I have not included any code, however I don't even know where to start. I have written several programs involving databases, but this is my first attempting to use drawings. Thanks in advance for any advice!! https://i.stack.imgur.com/gfKS9.jpg

  • I apologize the photo didnt post, it is here ..... http://i.stack.imgur.com/gfKS9.jpg – Caleb Ewing Apr 20 '15 at 04:39
  • Did you look at the way that LC stores the coordinates for your drawing? You should be able to edit these values stored in the properties with your updated measurement and then redraw the whole window. – Tate83 Apr 20 '15 at 07:02
  • Thanks! do you know where i can find these coordinates? I know where the points are stored, but I have no idea how to translate these into the degree of angle – Caleb Ewing Apr 21 '15 at 00:53
  • Did you try using `revRotatePoly`? I'm guess this rotates the whole graphic not just the one line though. Thus you probably have to create your own function using some geometric calculations to redraw the last part of the polygon at another angle. I cannot test just now but this should not be too difficult in a 2D area. – Tate83 Apr 21 '15 at 07:17
  • I think you're right. I may have to do it as several separate polygons, one for each line segment, that way they can be rotated individually. Unfortunately math is not my strong suit haha. That will cause a whole new host of problems however as I will have to figure out how to write a function that will rotate the poly off of the connected edge as opposed to the center of the graphic – Caleb Ewing Apr 22 '15 at 01:36
  • I guess that will be the way. Even though I cannot remember the maths fully right now it shouldn't be too hard to write a function to convert polar coordinates (x/y-axis) to an angle and the other way round. This looks about right: https://www.mathsisfun.com/polar-cartesian-coordinates.html – Tate83 Apr 22 '15 at 06:58

2 Answers2

0

You can't change the size of a single segment but all polygon. To change the size of the line...

set the linesize of graphic "polygon" to 4

Paolo

Neurox66
  • 1
  • 1
  • Paolo, thanks for the response. Changing the "linesize" just changes the thickness of the drawn line, not the length. Unless i'm missing something? – Caleb Ewing Apr 21 '15 at 00:52
0

To get the angle you can use some trigonometry. if you have two points (which you can get by using

 the points of graphic "myPolygon"

Then you get one point per line. If you want to calculate the angle between two points you can use some trigonometry. If you have a point x1, y1 and another point x2,y2 you get the angle by using

put atan2(y2-y1, x2-x1) into tRad

The angle will be in radians from -pi to +pi so you need to convert it to degrees if you want more "regular" degrees:

put tRad*180/pi into tDeg

The angle you get is according to the x-y coordinate system. So if you want the angle between to lines you need to do two calculations and add the angles.

hliljegren
  • 426
  • 3
  • 9