sunLoadingImage
whowedImag
decoration left 1
decoration left 2
transhome
transprojects
transgallery
transarticles
decoration rigth
English

Show/Hide search bar
black cat logo variable logo
[02 Nov 2012]

Trigonometry in Computer Graphics

During implementation of geometrical methods or development of shaders it's often required to make best possible optimizations to reduce number of calls of costly trigonometrical functions. Following article contains formulas that can be used during optimizations.

Angles

Radian is the unit of angular measure for 2D angles. One radian corresponds to arc of a circle with length that is equal radius of the circle.

  • Transformation of degrees to radians
  • Transformation of radians to angles

Trigonometrical functions
From right triangle:
Right triangle
we get:
          
          
          

Reflected angle





Angle and shift of 90 degrees





Other basic relations





Angle sum and difference





Double-angle





Laws of cosines and sines

From arbitrary triangle:
Arbitrary triangle
we get:
Calculation of unknown side of triangle through two other sides and opposite angle
Calculation of unknown side of triangle through two other sides and adjacent angle
Calculation of angle through tree sides
Law of sines



Sun and Black Cat- Igor Dykhta (igor dykhta email) 2007-2014