Everything2
Near Matches
Ignore Exact
Full Text
Everything2

rotation

"rotation" is also a: user

created by takeru

(idea) by intromorph (7.7 y) (print)   ?   I like it! Fri Aug 18 2000 at 22:57:28

for a really long time, i tried to get a program that did rotation to work and found this difficult as nearly all of the info provided on the subject assume knowledge of matrices. thus, here are the formulas for rotation in simple algebra in cartesian coordinate space:

x axis:
y' = y * cos(a) - z * sin(a)
z' = z * cos(a) + y * sin(a)

y axis:
z' = z * cos(a) - x * sin(a)
x' = x * cos(a) + z * sin(a)

z axis:
x' = x * cos(a) - y * sin(a)
y' = y * cos(a) + x * sin(a)

remember that if you are using these formulas as part of a programming exercise, z' is NOT the same as z so if you say something like:

z' = z * cos(a) - x * sin(a)
x' = x * cos(a) + z' * sin(a)

you will wind up with really wacked out results.


(idea) by abiessu (13.2 hr) (print)   ?   I like it! Sat Oct 06 2001 at 4:19:47

Here is another method for achieving a rotational effect, based on having only distances, not angles:

                 ,.onOK|||||HQme., (x,y) 
            ,.szF'``           ``'Tux.,
    (u,v) ,z'``       ____,..---*''/``'c,
        ,x'`_,..---*'`            /    `'w,
      .u'\,            d         /       `'n.
     dy`  `\,                   /          `qb
    /7      `\,                /             VA
   4y         `\,             /               KD,
  ,I'           `\,          /                `VA
  dp              `\,       /                  qb
 ,j'                `\,    /                   `t,
 AV                   `\, /          r          VA
 69                      O----------------------96
 VA                    (w,z)                    AV
 `t,                                           ,j'
  qb                                           dp
  `I,                                         ,U'
   \D                                         4y'
    VA                                       /7'
     qb,                                   ,dy
      `'n.                               .u'`
        `'w,                           ,x'`
          `'c,,                     ,,z'`
            `'Tux.,,           ,,.szF'`
                 `'TTOKQQQQQH@TT'`

From the above points, let (x,y) be the starting point, (w,z) the center of rotation, and d the distance to the new point. In other words, the rotation is counterclockwise from (x,y) to a point d in distance from (x,y) about (w,z).

Let r be the distance from (x,y) to (w,z) (i.e., the radius of rotation) and define c=sqrt(r2-(d/2)2) (a helpful constant). Since r is a distance, r=sqrt((x-w)2+(y-z)2).

From this we get:

u = w+((x-w)⋅(c2-(d/2)2)-(y-z)⋅d⋅c)/r2
v = z+((y-z)⋅(c2-(d/2)2)+(x-w)⋅d⋅c)/r2

Thanks to jrn for noticing that supplying a negative number for d will cause a clockwise rotation.


Below is my LISP code to achieve such a rotation. Note that the rotation function will return nil if abs(d) is more than twice as big as the distance from the starting point to the center of rotation (i.e., c is not a real number).

(defun distance (p1 p2)
  "Takes two points and finds the distance between them."
  (when (and (consp p1)
             (consp p2)
             (> (length p1) 1)
             (> (length p2) 1)
             (every 'numberp p1)
             (every 'numberp p2))
    (sqrt (+ (expt (- (first p1) (first p2)) 2)
             (expt (- (second p1) (second p2)) 2)))))

(defun distance-rotate (p c d)
  "Takes a point p, a center of rotation c, and a distance d.
Rotates counter-clockwise about c to a point d away from p.
Use a negative number for d to get a clockwise rotation."
  (when (and (numberp d) (distance p c))
    (let* ((r (distance p c))
           (k (sqrt (- (expt r 2) (expt (/ d 2) 2))))
           (dx (- (first p) (first c)))
           (dy (- (second p) (second c))))
      (when (< (abs d) (* 2 r))
        `(,(+ (first c)
              (/ (- (* dx (- (expt k 2) (expt (/ d 2) 2)))
                    (* dy k d)) (* r r)))
          ,(+ (second c)
              (/ (+ (* dy (- (expt k 2) (expt (/ d 2) 2)))
                    (* dx k d)) (* r r))))))))

(definition) by Webster 1913 (print) I like it! Wed Dec 22 1999 at 2:46:00

Ro*ta"tion (?), n. [L. rotatio: cf. F. rotation.]

1.

The act of turning, as a wheel or a solid body on its axis, as distinguished from the progressive motion of a revolving round another body or a distant point; thus, the daily turning of the earth on its axis is a rotation; its annual motion round the sun is a revolution.

2.

Any return or succession in a series.

Moment of rotation. See Moment of inertia, under Moment. -- Rotation in office, the practice of changing public officers at frequent intervals by discharges and substitutions. -- Rotation of crops, the practices of cultivating an orderly succession of different crops on the same land.

 

© Webster 1913.


Ro*ta"tion (?), a.

Pertaining to, or resulting from, rotation; of the nature of, or characterized by, rotation; as, rotational velocity.

 

© Webster 1913.


printable version
chaos

Playing the Nokia rotation game circle rotation matrix swavastika
Elliptic integral Continuous function fractals Nokia Cogwheel
&oplus; If cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl cyclohedron Power Ball
orthonormal matrix A/C curtate cycloid nth roots of unity
fractional linear transformation Markab Kerr metric How to throw a disc
funnel cloud bothersome nuance multiplicative inverse Ellipsoid
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Things you could have written:
Dr. Seuss
dwarf planet
Space Ghost Coast to Coast
Mario Lemieux
One-pixel transparent GIF
Mystic River
rampaging wenchbeast
Meiosis
Wild at Heart
Timur
Talking like a pirate is fun but annoys people
Prosenoder's Cup 2003
Granny shot
New Writeups
locke baron
Tyan Thunder K8WE(thing)
locke baron
Udaloy class destroyer(thing)
Scaevola
Same-sex marriage(idea)
SteveMurrayFromNZ
Waiver(idea)
nailbiter
nerve stapling(thing)
locke baron
Multiple Myeloma(thing)
SubSane
blonde, freckles, skinny, short(person)
arcanamundi
A Ruba'iyat for May(person)
riverrun
Timed Writing(idea)
auraseer
Fling(fiction)
StrawberryFrog
Iron Man(review)
devolution
Misogyny and Porn, East to West - An Empirical Analysis(idea)
devolution
Korea is a place that refuses to stand still(idea)
Beanie127
The Pacifist Soldier(fiction)
VergilKint
Distilled from Dreams(fiction)
Everything 2 is brought to you by the letter C and The Everything Development Company