Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Environment and Utilities /
Chapter 8 - QuickDraw GX Mathematics / About QuickDraw GX Mathematics


Mathematical Functions

QuickDraw GX provides mathematical functions for

A description of each QuickDraw GX mathematics function is provided in the section "Mathematical Functions" beginning on page 8-42.

Operations on Fixed, long, and fract Numbers

QuickDraw GX provides functions that perform operations on Fixed, long, and fract number formats. Functions are provided that

The functions that perform operations on Fixed, long, and fract number formats are described in the section "Fixed-Point Operations" beginning on page 8-42.

Operations on wide Numbers

QuickDraw GX provides functions for operations on wide numbers. Functions are provided that

The functions that perform operations on wide number formats are described in the section "Operations on wide Numbers" beginning on page 8-49.

Vector Operations

QuickDraw GX provides vector operation functions that

The use of QuickDraw GX vector operation functions is described in the section "Performing Vector Operations" beginning on page 8-29. These functions are described in the section "Vector Operations" beginning on page 8-54.

Cartesian and Polar Coordinate Conversion

You use Cartesian coordinates to specify points with QuickDraw GX. Some shapes, such as rectangles, are more easily drawn using Cartesian coordinates; however, some shapes that have symmetry about a point are more easily drawn with polar coordinates. For that reason, QuickDraw GX provides conversion routines so that you can work in either coordinate system.

For QuickDraw GX, Cartesian coordinates have a positive x direction to the right and a positive y direction downward (not upward, as in many other Cartesian coordinate systems). Cartesian coordinates are written in the order (x, y). The origin is at (0, 0). The gxPoint structure describes points using Cartesian coordinates.

Polar coordinates have the same origin point as Cartesian coordinates, but locations are specified differently. The polar coordinate of a point is specified by the length of the radius vector r from the origin to the point and the direction of the vector is specified by polar angle a. Angles in QuickDraw GX are measured clockwise in degrees from the Cartesian coordinate positive x-axis. The polar coordinate of a point specified by a vector of length r and direction a degrees from the x-axis is written as point (r, a). The polar origin point has the coordinates (0, a), where a is any angle. Points having polar coordinates are defined by the gxPolar structure. The gxPolar structure is described in the section "Constants and Data Types" beginning on page 8-35. The relationship of the Cartesian and polar coordinates is shown in Figure 8-1.

Figure 8-1 Cartesian and polar coordinates

The gxPolar location (r, a) corresponds to the gxPoint location (r cos(a), r sin(a)). The mathematical relationship between the two coordinate systems is given by the expressions r2 = x2 + y2 and tan(a / 2) = y / (r + x). The angle can also be defined by the more familiar term tan(a) = y / x.

The use of the polar-to-Cartesian and Cartesian-to-polar coordinates functions are described in the section "Converting Between Cartesian and Polar Coordinates" beginning on page 8-29. These functions are described in the section "Cartesian and Polar Coordinate Point Conversions" beginning on page 8-56.

Random Number Generation

The QuickDraw GX random-number algorithm generates random integers in the range of 0 to 2count - 1, where count is the number of bits to be generated by the random number generator.

The sequence of values that the random number generator produces is dependent upon the initialization value called the seed. The algorithm uses the seed to calculate the next random number and a new seed. If no seed is provided, QuickDraw GX uses a default seed value of 0. To repeat a sequence of random numbers, you can use the same seed value.

QuickDraw GX provides random number generation functions that

The use of the random number generation functions is described in the section "Generating Random Numbers" beginning on page 8-33. These functions are described in the section "Random Number Generation" beginning on page 8-58.

Roots of Linear and Quadratic Equations

QuickDraw GX provides mathematical functions that

The linear and quadratic equation solving functions are described in the section "Linear and Quadratic Roots" beginning on page 8-60.

Bit Analysis

QuickDraw GX provides a mathematical function that allows you to determine the highest bit number that is set in a number.

The FirstBit function is described in the section "Bit Analysis" beginning on page 8-62.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996