forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.sass
More file actions
42 lines (37 loc) · 1009 Bytes
/
Copy pathmath.sass
File metadata and controls
42 lines (37 loc) · 1009 Bytes
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
$PI: 3.14159265359
@function pow($number, $exp)
$value: 1
@if $exp > 0
@for $i from 1 through $exp
$value: $value * $number
@else if $exp < 0
@for $i from 1 through -$exp
$value: $value / $number
@return $value
@function fact($number)
$value: 1
@if $number > 0
@for $i from 1 through $number
$value: $value * $i
@return $value
// round to number of decimals
// toFixed(0.12345, 100) -> 0.12
// toFixed(0.12345, 1000) -> 0.123
@function toFixed($number, $power)
@return round($number * $power) / $power
@function sin($angle)
$sin: 0
// angle -> radians
$rad: $angle / 180 * $PI
// interval determines precision
@for $i from 0 through 25
$sin: $sin + pow(-1, $i) * pow($rad, (2 * $i + 1)) / fact(2 * $i + 1)
@return $sin
@function cos($angle)
$cos: 0
// angle -> radians
$rad: $angle / 180 * $PI
// interval determines precision
@for $i from 0 through 25
$cos: $cos + pow(-1, $i) * pow($rad, 2 * $i) / fact(2 * $i)
@return $cos