Module PDF::Math
In: lib/pdf/math.rb

Encapsulate some of the mathematical calculations that need to be performed when working with PDF documents. All angles in PDF::Writer are measured in degrees, but all angles in PDF documents are in radians. The standard conversions between radians, degrees, and gradians are provided.

As with the Perl implementations of these conversions, they will be wrapped in the range of the target measurement (0..PI2 for radians, 0..360 for degrees, and 0..400 for gradians). To prevent this wrapping, provide a false value for the wrap parameter.

To wrap these values manually, use rad2rad, deg2deg, or grad2grad.

Methods

deg2deg   deg2grad   deg2rad   grad2deg   grad2grad   grad2rad   rad2deg   rad2grad   rad2rad   remt  

Constants

PI2 = ::Math::PI * 2.0
DR = PI2 / 360.0   One degree of arc measured in terms of radians.
RD = 360 / PI2   One radian of arc, measured in terms of degrees.
DG = 400 / 360.0   One degree of arc, measured in terms of gradians.
GD = 360 / 400.0   One gradian of arc, measured in terms of degrees.
RG = 400 / PI2   One radian of arc, measured in terms of gradians.
GR = PI2 / 400.0   One gradian of arc, measured in terms of radians.

Public Class methods

Wrap degree values within the range of degrees (0..360).

Convert degrees to gradians. The value will be constrained to the range of gradians (0..400) unless wrap is false.

Convert degrees to radians. The value will be constrained to the range of radians (0..PI2) unless wrap is false.

Convert gradians to degrees. The value will be constrained to the range of degrees (0..360) unless wrap is false.

Wrap gradian values within the range of gradians (0..400).

Convert gradians to radians. The value will be constrained to the range of radians (0..PI2) unless wrap is false.

Convert radians to degrees. The value will be constrained to the range of degrees (0..360) unless wrap is false.

Convert radians to gradians. The value will be constrained to the range of gradians (0..400) unless wrap is false.

Wrap radian values within the range of radians (0..PI2).

Truncate the remainder.

[Validate]