qball 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. .TH QBALL 2
  2. .SH NAME
  3. qball \- 3-d rotation controller
  4. .SH SYNOPSIS
  5. .PP
  6. .B
  7. #include <draw.h>
  8. .PP
  9. .B
  10. #include <geometry.h>
  11. .PP
  12. .B
  13. void qball(Rectangle r, Mouse *mousep,
  14. .br
  15. .B
  16. Quaternion *orientation,
  17. .br
  18. .B
  19. void (*redraw)(void), Quaternion *ap)
  20. .SH DESCRIPTION
  21. .I Qball
  22. is an interactive controller that allows arbitrary 3-space rotations to be specified with
  23. the mouse. Imagine a sphere with its center at the midpoint of rectangle
  24. .IR r ,
  25. and diameter the smaller of
  26. .IR r 's
  27. dimensions. Dragging from one point on the sphere to another specifies the endpoints of a
  28. great-circle arc. (Mouse points outside the sphere are projected to the nearest point
  29. on the sphere.) The axis of rotation is normal to the plane of the arc, and the
  30. angle of rotation is twice the angle of the arc.
  31. .PP
  32. Argument
  33. .I mousep
  34. is a pointer to the mouse event that triggered the interaction. It should
  35. have some button set.
  36. .I Qball
  37. will read more events into
  38. .IR mousep ,
  39. and return when no buttons are down.
  40. .PP
  41. While
  42. .I qball
  43. is reading mouse events, it calls out to the caller-supplied routine
  44. .IR redraw ,
  45. which is expected to update the screen to reflect the changing orientation.
  46. Argument
  47. .I orientation
  48. is the orientation that
  49. .I redraw
  50. should examine, represented as a unit Quaternion (see
  51. .IR quaternion(9.2)).
  52. The caller may set it to any orientation.
  53. It will be updated before each call to
  54. .I redraw
  55. (and on return) by multiplying by the rotation specified with the mouse.
  56. .PP
  57. It is possible to restrict
  58. .I qball's
  59. attention to rotations about a particular axis.
  60. If
  61. .I ap
  62. is null, the rotation is unconstrained.
  63. Otherwise, the rotation will be about the same axis as
  64. .IR *ap .
  65. This is accomplished by projecting points on the sphere to
  66. the nearest point also on the plane through the sphere's center
  67. and normal to the axis.
  68. .SH SOURCE
  69. .B /sys/src/libgeometry/qball.c
  70. .SH SEE ALSO
  71. .IR quaternion (2)
  72. .br
  73. Ken Shoemake,
  74. ``Animating Rotation with Quaternion Curves'',
  75. .I
  76. SIGGRAPH '85 Conference Proceedings.