Skip to content

Commit c8b5d73

Browse files
committed
Fix inc/dec to follow language conventions
1 parent e980861 commit c8b5d73

File tree

4 files changed

+14
-77
lines changed

4 files changed

+14
-77
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ repositories {
2424
}
2525
2626
dependencies {
27-
implementation 'dev.romainguy:kotlin-math:1.0.0'
27+
implementation 'dev.romainguy:kotlin-math:1.0.1'
2828
}
2929
```
3030

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
GROUP=dev.romainguy
2-
VERSION_NAME=1.0.0
2+
VERSION_NAME=1.0.1
33

44
POM_DESCRIPTION=Graphics oriented math library for Kotlin
55

src/main/kotlin/dev/romainguy/kotlin/math/Matrix.kt

+6-36
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,8 @@ data class Mat2(
6666
}
6767

6868
operator fun unaryMinus() = Mat2(-x, -y)
69-
operator fun inc(): Mat2 {
70-
x++
71-
y++
72-
return this
73-
}
74-
operator fun dec(): Mat2 {
75-
x--
76-
y--
77-
return this
78-
}
69+
operator fun inc() = Mat2(x++, y++)
70+
operator fun dec() = Mat2(x--, y--)
7971

8072
operator fun plus(v: Float) = Mat2(x + v, y + v)
8173
operator fun minus(v: Float) = Mat2(x - v, y - v)
@@ -159,18 +151,8 @@ data class Mat3(
159151
}
160152

161153
operator fun unaryMinus() = Mat3(-x, -y, -z)
162-
operator fun inc(): Mat3 {
163-
x++
164-
y++
165-
z++
166-
return this
167-
}
168-
operator fun dec(): Mat3 {
169-
x--
170-
y--
171-
z--
172-
return this
173-
}
154+
operator fun inc() = Mat3(x++, y++, z++)
155+
operator fun dec() = Mat3(x--, y--, z--)
174156

175157
operator fun plus(v: Float) = Mat3(x + v, y + v, z + v)
176158
operator fun minus(v: Float) = Mat3(x - v, y - v, z - v)
@@ -309,20 +291,8 @@ data class Mat4(
309291
}
310292

311293
operator fun unaryMinus() = Mat4(-x, -y, -z, -w)
312-
operator fun inc(): Mat4 {
313-
x++
314-
y++
315-
z++
316-
w++
317-
return this
318-
}
319-
operator fun dec(): Mat4 {
320-
x--
321-
y--
322-
z--
323-
w--
324-
return this
325-
}
294+
operator fun inc() = Mat4(x++, y++, z++, w++)
295+
operator fun dec() = Mat4(x--, y--, z--, w--)
326296

327297
operator fun plus(v: Float) = Mat4(x + v, y + v, z + v, w + v)
328298
operator fun minus(v: Float) = Mat4(x - v, y - v, z - v, w - v)

src/main/kotlin/dev/romainguy/kotlin/math/Vector.kt

+6-39
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,8 @@ data class Float2(var x: Float = 0.0f, var y: Float = 0.0f) {
117117
}
118118

119119
operator fun unaryMinus() = Float2(-x, -y)
120-
operator fun inc(): Float2 {
121-
x += 1.0f
122-
y += 1.0f
123-
return this
124-
}
125-
126-
operator fun dec(): Float2 {
127-
x -= 1.0f
128-
y -= 1.0f
129-
return this
130-
}
120+
operator fun inc() = Float2(x++, y++)
121+
operator fun dec() = Float2(x--, y--)
131122

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

293284
operator fun unaryMinus() = Float3(-x, -y, -z)
294-
operator fun inc(): Float3 {
295-
x += 1.0f
296-
y += 1.0f
297-
z += 1.0f
298-
return this
299-
}
300-
301-
operator fun dec(): Float3 {
302-
x -= 1.0f
303-
y -= 1.0f
304-
z -= 1.0f
305-
return this
306-
}
285+
operator fun inc() = Float3(x++, y++, z++)
286+
operator fun dec() = Float3(x--, y--, z--)
307287

308288
inline operator fun plus(v: Float) = Float3(x + v, y + v, z + v)
309289
inline operator fun minus(v: Float) = Float3(x - v, y - v, z - v)
@@ -543,21 +523,8 @@ data class Float4(
543523
}
544524

545525
operator fun unaryMinus() = Float4(-x, -y, -z, -w)
546-
operator fun inc(): Float4 {
547-
x += 1.0f
548-
y += 1.0f
549-
z += 1.0f
550-
w += 1.0f
551-
return this
552-
}
553-
554-
operator fun dec(): Float4 {
555-
x -= 1.0f
556-
y -= 1.0f
557-
z -= 1.0f
558-
w -= 1.0f
559-
return this
560-
}
526+
operator fun inc() = Float4(x++, y++, z++, w++)
527+
operator fun dec() = Float4(x--, y--, z--, w--)
561528

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

0 commit comments

Comments
 (0)