Article View: comp.sys.mac
Article #18609Re: Rotation Algorithm needed
From: avjewe
Date: Mon, 31 Aug 1987 11:42
Date: Mon, 31 Aug 1987 11:42
27 lines
1633 bytes
1633 bytes
In article <2180@mulga.oz> jteh@mulga.oz (J.T. Teh) writes:
>I need a rotation algorithm that will allow me to rotate the contents of
>a bounding rectangle at a given angle. Currently, I am using the standard
>algorithm of rotating the point around the origin with
> [ cosX -sinX ][ x ]
> [ sinX cosX ][ y ]
>but this causes the resultant image to have "holes" in it if I am rotating
Your algorithm is correct, just run it backwards. That is for each
point in the destination rectangle, calculate which point in the
original maps to it. Presto! no holes.
As for your speed problem, I think your out of luck. There are three
things I can think of (probobly many I can't) none of which are very
helpful.
1) special cases (30, 45, 90 and such)
2) rotate objects rather than dots if available
3) rather than the sin and cosine functions, use pre-filled arrays
(e.g. sin[45] instead of sin(45). This only works if you have a
well defined small domain)
Hope this helps,
Andy Jewell
disclaimer: I don't really know much about this stuff
Technical Details
Message-ID:
<2442@cvl.umd.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!seismo!mimsy!cvl!avjeweReferences:
<2180@mulga.oz>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!seismo!mimsy!cvl!avjewe From: avjewe@cvl.UUCP Newsgroups: comp.sys.mac Subject: Re: Rotation Algorithm needed Message-ID: <2442@cvl.umd.edu> Date: Mon, 31-Aug-87 07:42:57 EDT Article-I.D.: cvl.2442 Posted: Mon Aug 31 07:42:57 1987 Date-Received: Tue, 1-Sep-87 03:45:44 EDT References: <2180@mulga.oz> Reply-To: avjewe@cvl.UUCP (Andrew V Jewell) Organization: Center for Automation Research, Univ. of Md. Lines: 27 Keywords: Rotation, Mac