1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
---
title: Compass Math Helpers
crumb: Math
framework: compass
meta_description: Helper math functions.
layout: core
classnames:
- reference
- core
- helpers
documented_functions:
- "pi"
- "sin"
- "cos"
- "tan"
- "e"
- "log"
- "sqrt"
- "pow"
---
%h1 Compass Math Helpers
:markdown
Sass math functions are sufficient for most cases, but in those moments of extreme geekiness these additional functions can really come in handy.
#pi.helper
%h3
%a(href="#pi")
pi()
.details
%p
Returns the value of π.
#sin.helper
%h3
%a(href="#sin")
sin(<span class="arg">$number</span>)
.details
%p
Returns the sine of a number. If the number is unitless or has a unit of <code>deg</code>
then it will return a unitless result. Unless the number has a unit of <code>deg</code> it
will be evaluated as radians. Degrees will first be converted to radians.
If the number is any other unit, the units will be passed thru to the result,
and the number will be treated as radians.
#cos.helper
%h3
%a(href="#cos")
cos(<span class="arg">$number</span>)
.details
%p
Returns the cosine of a number. If the number is unitless or has a unit of <code>deg</code>
then it will return a unitless result. Unless the number has a unit of <code>deg</code> it
will be evaluated as radians. Degrees will first be converted to radians.
If the number is any other unit, the units will be passed thru to the result,
and the number will be treated as radians.
#tan.helper
%h3
%a(href="#tan")
tan(<span class="arg">$number</span>)
.details
%p
Returns the tangent of a number. If the number is unitless or has a unit of <code>deg</code>
then it will return a unitless result. Unless the number has a unit of <code>deg</code> it
will be evaluated as radians. Degrees will first be converted to radians.
If the number is any other unit, the units will be passed thru to the result,
and the number will be treated as radians.
#e.helper
%h3
%a(href="#e")
e()
.details
%p
Returns the value of <a href="http://en.wikipedia.org/wiki/E_(mathematical_constant)">e</a>.
#log.helper
%h3
%a(href="#log")
log(<span class="arg">$number</span>, <span class="arg" data-default-value="e" title="Defaults to: e">$base</span>)
.details
%p
Calculates the logarithm of a number to a base. Base defaults to <code>e</code>.
#sqrt.helper
%h3
%a(href="#sqrt")
sqrt(<span class="arg">$number</span>)
.details
%p
Calculates the square root of a number.
#pow.helper
%h3
%a(href="#pow")
pow(<span class="arg">$number</span>, <span class="arg">$exponent</span>)
.details
%p
Calculates the value of a number raised to the power of an exponent.
|