Rotating an Oval

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
paulgr
Posts: 7
Joined: Mon May 01, 2006 9:31 pm

Rotating an Oval

Post by paulgr » Sat Jul 29, 2006 8:29 pm

Hi All,
I do appear to have one sticking point with Rev -- it's inability (or maybe my inability to get it to work) to rotate a vector that contains a smooth curved edge -- like an Oval.
I have an Object (Oval vector) following a randomly generated bezier path -- I want the vector to turn and point along the path as it goes along the path.
No problem with the path and moving the object along it, but rotating/turning as it goes seems impossible.

I have read all the documentation and noted the differences between angle, rotation and revRotatePoly.
Docs say use the revRotatePoly command to rotate a line, curve, or irregular polygon graphic, and use angle to set the angle of a regular polygon or image.
Doesn't seem to leave much to rotate an oval with.

I have come to the conclusion (possibly wrong) that it is impossible to rotate a vector oval, using either revrotatepoly or the angle function.
I have read through the many rotation/angle references in the user group, and I did gain some useful insight through the opinions of Jim Hurley, Malte and a few others that have commented on this subject.

The inability of being able to rotate a smooth curved vector is a major disincentive to me using Rev, as many games require this.

I can rotate an image of course, but then you lose the hard smooth edge that vectors give.

If anyone can show me the way through this problem, what I am doing wrong, or has a workaround, I would appreciate it. I can't believe a simple thing like rotating a vector containing a smooth curve is so difficult.

cheers
Paul

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sat Jul 29, 2006 10:19 pm

Hi paul,

It is not possible to rotate an oval in rev. This is just speaking of the built in oval object. If you calculate the points of the oval beforehand and use an irregular poly to display it, you can rotate that. For most purposes that should do the trick, howeverr it would be nice to have it as a built in property.

All the best,

Malte

Benedikt.Seidl
Posts: 9
Joined: Sat Apr 08, 2006 3:54 pm

Post by Benedikt.Seidl » Sat Jul 29, 2006 11:04 pm

i like those little mathematic problems, so i wrote a function for you:

Code: Select all

function ro_el twidth, theight, tlocx, tlocy, tangle
  repeat with i = 0  to 360
    put (sin((i)/180*pi)*(twidth))  into x
    put (cos((i)/180*pi)*(theight)) into y
    put   round(x * cos(tangle/180*pi) + y * sin(tangle/180*pi) + tlocx) & comma & \
          round(y * cos(tangle/180*pi) - x * sin(tangle/180*pi) + tlocy) & cr after tpoints
  end repeat
return tpoints
end ro_el
go stack URL "http://swine.de/daten/oval.rev" <- the function in action


SEIDL.

paulgr
Posts: 7
Joined: Mon May 01, 2006 9:31 pm

Post by paulgr » Sun Jul 30, 2006 1:59 am

Thanks Malte for confirming my thoughts -- I guess I've just have to work in straight lines from now on.

Thanks for your code, SEIDL.
I have tried building an oval with code in a similar way to your suggestion already, but can't get the smooth curve I'm after this way, at least on XP.

I'll just use other shapes in more inventive ways :-)

cheers
Paul

DarScott
Posts: 227
Joined: Fri Jul 28, 2006 12:23 am
Contact:

Post by DarScott » Sun Jul 30, 2006 12:44 pm

malte wrote:It is not possible to rotate an oval in rev. This is just speaking of the built in oval object.
It is unfortunate that 'angle' is the same as 'startAngle' for ovals. That meaning is unlike the meaning for other controls. I would not mind if that changes to a meaning like the others. The change would break some scripts, though. It would be cool (if done well) to have an angle for groups, which would make the lack of real angle for oval less of a problem.

Post Reply