Skip to content

Commit

Permalink
Fix inc/dec to follow language conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
romainguy committed Nov 13, 2021
1 parent e980861 commit c8b5d73
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 77 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repositories {
}
dependencies {
implementation 'dev.romainguy:kotlin-math:1.0.0'
implementation 'dev.romainguy:kotlin-math:1.0.1'
}
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=dev.romainguy
VERSION_NAME=1.0.0
VERSION_NAME=1.0.1

POM_DESCRIPTION=Graphics oriented math library for Kotlin

Expand Down
42 changes: 6 additions & 36 deletions src/main/kotlin/dev/romainguy/kotlin/math/Matrix.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,8 @@ data class Mat2(
}

operator fun unaryMinus() = Mat2(-x, -y)
operator fun inc(): Mat2 {
x++
y++
return this
}
operator fun dec(): Mat2 {
x--
y--
return this
}
operator fun inc() = Mat2(x++, y++)
operator fun dec() = Mat2(x--, y--)

operator fun plus(v: Float) = Mat2(x + v, y + v)
operator fun minus(v: Float) = Mat2(x - v, y - v)
Expand Down Expand Up @@ -159,18 +151,8 @@ data class Mat3(
}

operator fun unaryMinus() = Mat3(-x, -y, -z)
operator fun inc(): Mat3 {
x++
y++
z++
return this
}
operator fun dec(): Mat3 {
x--
y--
z--
return this
}
operator fun inc() = Mat3(x++, y++, z++)
operator fun dec() = Mat3(x--, y--, z--)

operator fun plus(v: Float) = Mat3(x + v, y + v, z + v)
operator fun minus(v: Float) = Mat3(x - v, y - v, z - v)
Expand Down Expand Up @@ -309,20 +291,8 @@ data class Mat4(
}

operator fun unaryMinus() = Mat4(-x, -y, -z, -w)
operator fun inc(): Mat4 {
x++
y++
z++
w++
return this
}
operator fun dec(): Mat4 {
x--
y--
z--
w--
return this
}
operator fun inc() = Mat4(x++, y++, z++, w++)
operator fun dec() = Mat4(x--, y--, z--, w--)

operator fun plus(v: Float) = Mat4(x + v, y + v, z + v, w + v)
operator fun minus(v: Float) = Mat4(x - v, y - v, z - v, w - v)
Expand Down
45 changes: 6 additions & 39 deletions src/main/kotlin/dev/romainguy/kotlin/math/Vector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,8 @@ data class Float2(var x: Float = 0.0f, var y: Float = 0.0f) {
}

operator fun unaryMinus() = Float2(-x, -y)
operator fun inc(): Float2 {
x += 1.0f
y += 1.0f
return this
}

operator fun dec(): Float2 {
x -= 1.0f
y -= 1.0f
return this
}
operator fun inc() = Float2(x++, y++)
operator fun dec() = Float2(x--, y--)

inline operator fun plus(v: Float) = Float2(x + v, y + v)
inline operator fun minus(v: Float) = Float2(x - v, y - v)
Expand Down Expand Up @@ -291,19 +282,8 @@ data class Float3(var x: Float = 0.0f, var y: Float = 0.0f, var z: Float = 0.0f)
}

operator fun unaryMinus() = Float3(-x, -y, -z)
operator fun inc(): Float3 {
x += 1.0f
y += 1.0f
z += 1.0f
return this
}

operator fun dec(): Float3 {
x -= 1.0f
y -= 1.0f
z -= 1.0f
return this
}
operator fun inc() = Float3(x++, y++, z++)
operator fun dec() = Float3(x--, y--, z--)

inline operator fun plus(v: Float) = Float3(x + v, y + v, z + v)
inline operator fun minus(v: Float) = Float3(x - v, y - v, z - v)
Expand Down Expand Up @@ -543,21 +523,8 @@ data class Float4(
}

operator fun unaryMinus() = Float4(-x, -y, -z, -w)
operator fun inc(): Float4 {
x += 1.0f
y += 1.0f
z += 1.0f
w += 1.0f
return this
}

operator fun dec(): Float4 {
x -= 1.0f
y -= 1.0f
z -= 1.0f
w -= 1.0f
return this
}
operator fun inc() = Float4(x++, y++, z++, w++)
operator fun dec() = Float4(x--, y--, z--, w--)

inline operator fun plus(v: Float) = Float4(x + v, y + v, z + v, w + v)
inline operator fun minus(v: Float) = Float4(x - v, y - v, z - v, w - v)
Expand Down

0 comments on commit c8b5d73

Please sign in to comment.