Skip to content

Commit 92ac0ba

Browse files
authored
Merge pull request #77 from treeform/fmt
Formatting changes.
2 parents 76f5a1b + a9ea9ff commit 92ac0ba

12 files changed

Lines changed: 48 additions & 31 deletions

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Supports c, cpp and js backend.
1414

1515
## About
1616

17-
Your one stop shop for vector math routines for 2d and 3d graphics.
17+
Your one stop shop for vector math routines for 2D and 3D graphics.
1818

1919
* Pure Nim with no dependencies.
2020
* Very similar to GLSL Shader Language with extra stuff.
@@ -42,7 +42,7 @@ float64 | double | DVec2 | DVec3 | DVec4 | DMat3 | DMat4 | DQuat |
4242

4343
## 2D & 3D matrix math
4444

45-
You can combine and create 2d and 3d matrices by passing 2d or 3d vectors to matrix functions:
45+
You can combine and create 2D and 3D matrices by passing 2D or 3D vectors to matrix functions:
4646

4747
```nim
4848
let mat2d = translate(vec2(10, 20)) * rotate(45.toRadians) * scale(vec2(2))
@@ -63,15 +63,14 @@ quat(1.0, 2.0, 3.0, 4.0) ~= quat(1.0, 2.0, 3.0, 4.0)
6363

6464
* `between` - Returns true if value is between min and max or equal to them.
6565
* `sign` - Returns the sign of a number, -1 or 1.
66-
* `quantize` - Makes v be a multiple of n. Rounding to integer quantize by 1.0.
67-
* `fractional` - Returns fractional part of a number. 3.14 -> 0.14
66+
* `quantize` - Makes v be a multiple of n. Rounding to integer quantizes by 1.0.
6867
* `lerp` - Interpolates value between a and b.
6968

7069
## Angle functions
7170

72-
* `fixAngle` - Make angle be from -PI to PI radians.
73-
* `angleBetween` - Find the angle between angle a and angle b.
74-
* `turnAngle` - Move from angle a to angle b with step of v.
71+
* `fixAngle` - Makes angle be from -PI to PI radians.
72+
* `angleBetween` - Finds the angle between angle a and angle b.
73+
* `turnAngle` - Moves from angle a to angle b with step of v.
7574

7675
## Vector and matrix representation and benchmarks.
7776

@@ -93,11 +92,11 @@ vmathObjArrayBased ................ 73.968 ms 74.292 ms ±0.631 x100
9392

9493
## Zmod - GLSL mod
9594

96-
GLSL uses a different type of float point mod. Because mod is a Nim keyword please use `zmod` when you need GLSL `mod` behavior.
95+
GLSL uses a different type of float point mod. Because mod is a Nim keyword, please use `zmod` when you need GLSL `mod` behavior.
9796

9897
## Coordinate System
9998

100-
Right-hand z-forward coordinate system
99+
Right-hand Z-forward coordinate system
101100

102101
This is the same system used in the GLTF file format.
103102

@@ -124,18 +123,18 @@ OpenGL/GLSL/vmath vs Math/Specification notation:
124123
```
125124

126125
# 1.x.x to 2.0.0 vmath breaking changes:
127-
* New right-hand-z-forward cordate system and functions that care about
128-
coordinate system where moved there.
129-
* deprecated `lookAt()` please use `toAngles()`/`fromAngles()` instead.
130-
* deprecated `fractional()` use `frac()` instead.
126+
* New right-hand-Z-forward coordinate system and functions that care about
127+
coordinate system were moved there.
128+
* Deprecated `lookAt()`, please use `toAngles()`/`fromAngles()` instead.
129+
* Deprecated `fractional()`, use `frac()` instead.
131130

132131
# 0.x.x to 1.0.0 vmath breaking changes:
133132

134-
* `vec3(v)` no longer works please use `vec3(v.x, v.y, 0)` instead.
135-
* `vec3(v, 0)` no longer works please use `vec3(v.x, v.y, 0)` instead.
136-
* `2 * v` no longer works due to more vec types please use `v * 2` instead.
133+
* `vec3(v)` no longer works, please use `vec3(v.x, v.y, 0)` instead.
134+
* `vec3(v, 0)` no longer works, please use `vec3(v.x, v.y, 0)` instead.
135+
* `2 * v` no longer works due to more vec types, please use `v * 2` instead.
137136
* `m[15]` no longer works because matrices are now m[x, y].
138-
* Concept of 3x3 rotation 3d matrix was removed.
137+
* Concept of 3x3 rotation 3D matrix was removed.
139138
* `angleBetween` got renamed to `angle(a, b)`
140139
* `scaleMat` got renamed to `scale(v)`
141140
* `rotationMat3` got renamed to `rotate(x)`

src/vmath.nim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ float64 double DVec2 DVec3 DVec4 DMat3 DMat4 DQuat
3030
3131
]##
3232

33-
import macros, math, strutils
33+
import
34+
std/[macros, math, strutils]
3435
export math except isNan
3536

3637
{.push inline.}
@@ -389,8 +390,8 @@ type
389390

390391
proc `~=`*[T: SomeFloat](a, b: T): bool =
391392
## Almost equal.
392-
const epsilon = 0.000001
393-
abs(a - b) <= epsilon
393+
const Epsilon = 0.000001
394+
abs(a - b) <= Epsilon
394395

395396
proc between*[T](value, min, max: T): bool =
396397
## Returns true if value is between min and max or equal to them.
@@ -411,7 +412,7 @@ proc fract*[T: SomeFloat](v: T): T =
411412
result = abs(v)
412413
result = result - trunc(result)
413414

414-
proc fractional*[T: SomeFloat](v: T): T {.deprecated: "Use frac() insetad"} =
415+
proc fractional*[T: SomeFloat](v: T): T {.deprecated: "Use fract() instead"} =
415416
## Returns fractional part of a number.
416417
fract(v)
417418

src/vmath/macroswizzle.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11

2+
import
3+
std/[macros]
4+
25
{.experimental: "dotOperators".}
36
proc num(letter: char, fields: NimNode): int =
47
## Given a swizzle character gives back the location number.

src/vmath/swizzle.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by tools/gensswizzle - don't edit manually.
1+
# Generated by tools/genswizzle - don't edit manually.
22

33
# 1 x rgba
44
proc r*[T](a: GVec234[T]): T = a[0]

tests/bench.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import benchy, vmath
1+
import
2+
benchy,
3+
vmath
24

35
# TODO: I don't trust these simple benchmarks, make a better test.
46
# echo "new vmath"

tests/bench_isNan.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import benchy, vmath
1+
import
2+
benchy,
3+
vmath
24

35
proc isNaNSlow(f: SomeFloat): bool =
46
## Returns true if number is a NaN.

tests/bench_raytracer.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
## MIT License
33
## Copyright (c) 2021 Edin Omeragic
44

5-
import benchy, chroma, math, pixie, vmath
5+
import
6+
std/math,
7+
benchy, chroma, pixie, vmath
68

79
{.push inline, noinit, checks: off.}
810

tests/bench_raytracer_glm.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
## MIT License
33
## Copyright (c) 2021 Edin Omeragic
44

5-
import benchy, chroma, math, glm
5+
import
6+
std/math,
7+
benchy, chroma, glm
68
from pixie import Image, newImage, writeFile, dataIndex
79

810
type Vec3 = glm.Vec3[float32]

tests/bench_rep.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import benchy
1+
import
2+
benchy
23

34
type
45
Vec3Obj = object

tests/bench_swizzle.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import benchy, vmath
1+
import
2+
benchy,
3+
vmath
24

35
block:
46
var

0 commit comments

Comments
 (0)