Thanks Bernd, spot on.
Glad to hear that the problem is in Livecode and not somewhere between the computer and my chair.
It's working well, but I am now just encountering a little accumulative rounding issue. I will just write a couple of lines to keep track of actual figures and round them instead of rounding a rounded figure.
XdM
Inverse Kinematics
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Inverse Kinematics
Hi Xero,
I attach a stack that uses code from Robert Cailliau with small speed improvements by me.
It lets you rotate a polygon made up of points around an arbitrary rotation point. Pretty much what you want to do.
It is basically lossless, i.e. it does not accumulate rounding errors.
Robert achieves this by setting the polygon up with a couple of custom properties and use those to do the math for rotation.
The stack has buttons to initialize a polygon (which is necessary to do Robert's magic) and lets you turn it via a scrollbar.
Look at the scripts how the setUp works. The main code is in the card script.
Rename your polygon to "traceLine2". (you can use any other name when you change the setup buttons)
Position your polygon in its unturned upright position and hit either the button to rotate the polygon around the center of the card or around the last point of the pointlist of the polygon.
To monitor the effect of rotation on the polygon the width and height are displayed. Note that at angle 0 after multiple rotations the values stay constant.
Kind regards
Bernd
I attach a stack that uses code from Robert Cailliau with small speed improvements by me.
It lets you rotate a polygon made up of points around an arbitrary rotation point. Pretty much what you want to do.
It is basically lossless, i.e. it does not accumulate rounding errors.
Robert achieves this by setting the polygon up with a couple of custom properties and use those to do the math for rotation.
The stack has buttons to initialize a polygon (which is necessary to do Robert's magic) and lets you turn it via a scrollbar.
Look at the scripts how the setUp works. The main code is in the card script.
Rename your polygon to "traceLine2". (you can use any other name when you change the setup buttons)
Position your polygon in its unturned upright position and hit either the button to rotate the polygon around the center of the card or around the last point of the pointlist of the polygon.
To monitor the effect of rotation on the polygon the width and height are displayed. Note that at angle 0 after multiple rotations the values stay constant.
Kind regards
Bernd
- Attachments
-
- demo_R_Cailliau rotate Polygon.livecode.zip
- (5.48 KiB) Downloaded 161 times