Inverse Kinematics

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Xero
Posts: 157
Joined: Sat Jun 23, 2018 2:22 pm

Re: Inverse Kinematics

Post by Xero » Sun Nov 14, 2021 1:24 am

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

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Re: Inverse Kinematics

Post by bn » Sun Nov 14, 2021 6:32 pm

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
Attachments
demo_R_Cailliau rotate Polygon.livecode.zip
(5.48 KiB) Downloaded 162 times

Post Reply