home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / graphics / 13372 < prev    next >
Encoding:
Text File  |  1993-01-04  |  1.7 KB  |  41 lines

  1. Newsgroups: comp.graphics
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!convex!constellation!a.cs.okstate.edu!jmccorm
  3. From: jmccorm@a.cs.okstate.edu (MCCORMICK JOSHUA C)
  4. Subject: Re: fast bitmap rotation
  5. References: <726100620.1@freudsys.iaf>
  6. Message-ID: <1993Jan4.215419.7730@a.cs.okstate.edu>
  7. Organization: Oklahoma State University
  8. Date: Mon, 4 Jan 93 21:54:19 GMT
  9. Lines: 30
  10.  
  11. From article <726100620.1@freudsys.iaf>, by Renee.Teunissen@freudsys.iaf.nl (Renee Teunissen):
  12.  
  13. > I have the following "problem". for a Photo montage package i wrote a rotation tool for full color objects [bitmap images]. this program runs unther windows 3.1. but rotating these bitmaps goes very slow, eg if I do the same rotation [same image size and pixel depth] in PhotoStyler is goes much faster. anyone any smart idears about a pointer to a fast rotation algorithm ??
  14.  
  15. I'll tell you how I do my rotations. I hope it is of some help.
  16.  
  17. 1] Before the process begins, I build a table of all the SIN and COS
  18.    functions. This saves me the trouble of having to compute it for
  19.    each and every point (not to mention CPU time).
  20. 2] Then it's a simple matter of using the formula [if ROT is about 0,0]:
  21.  
  22. x' = x * cos (radians) - y * sin (radians)
  23. y' = y * cos (radians) + x * sin (radians)
  24.  
  25. radians = [Degrees Rotation] * Pi / 180
  26.  
  27. If you want to twirl the object around some other point besides (0,0) [which
  28. will probably take more CPU time than remapping the image] then use the
  29. formula...
  30.  
  31. x' = Xr + (X - Xr) * Cos (radians) - (Y - Yr) * Sin (radians)
  32. y' = Yr + (Y - Yr) * Cos (radians) + (X - Xr) * Sin (radians)
  33.  
  34. I hope this is of some use to you. Let me know, okay?
  35.  
  36. -- 
  37.  
  38. --- Josh McCormick
  39. --- jmccorm@a.cs.okstate.edu
  40. --- 1:3814/0 [user of 3814's NC]
  41.