Skip to content

Commit 9aba3bf

Browse files
committed
equals
1 parent ad39d2c commit 9aba3bf

40 files changed

+62
-119
lines changed

src/main/kotlin/glm_/mat2x2/Mat2.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,8 @@ data class Mat2(override var value: MutableList<Vec2>) : Mat2x2t<Vec2>(value) {
214214
fun isIdentity() = this[0][0] == 1f && this[1][0] == 0f && this[0][1] == 0f && this[1][1] == 1f
215215

216216
override fun toString() = super.toString()
217+
218+
override fun equals(other: Any?) = other is Mat2 &&
219+
this[0, 0] == other[0, 0] && this[0, 1] == other[0, 1] &&
220+
this[1, 0] == other[1, 0] && this[1, 1] == other[1, 1]
217221
}

src/main/kotlin/glm_/mat2x2/Mat2d.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,8 @@ data class Mat2d(override var value: MutableList<Vec2d>) : Mat2x2t<Vec2d>(value)
215215

216216

217217
override fun toString() = super.toString()
218+
219+
override fun equals(other: Any?) = other is Mat2 &&
220+
this[0, 0] == other[0, 0] && this[0, 1] == other[0, 1] &&
221+
this[1, 0] == other[1, 0] && this[1, 1] == other[1, 1]
218222
}

src/main/kotlin/glm_/mat3x3/Mat3.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,4 +374,9 @@ data class Mat3(override var value: MutableList<Vec3>) : Mat3x3t<Vec3>(value) {
374374

375375

376376
override fun toString() = super.toString()
377+
378+
override fun equals(other: Any?) = other is Mat3 &&
379+
this[0, 0] == other[0, 0] && this[0, 1] == other[0, 1] && this[0, 2] == other[0, 2] &&
380+
this[1, 0] == other[1, 0] && this[1, 1] == other[1, 1] && this[1, 2] == other[1, 2] &&
381+
this[2, 0] == other[2, 0] && this[2, 1] == other[2, 1] && this[2, 2] == other[2, 2]
377382
}

src/main/kotlin/glm_/mat3x3/Mat3d.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,9 @@ data class Mat3d(override var value: MutableList<Vec3d>) : Mat3x3t<Vec3d>(value)
358358

359359

360360
override fun toString() = super.toString()
361+
362+
override fun equals(other: Any?) = other is Mat3d &&
363+
this[0, 0] == other[0, 0] && this[0, 1] == other[0, 1] && this[0, 2] == other[0, 2] &&
364+
this[1, 0] == other[1, 0] && this[1, 1] == other[1, 1] && this[1, 2] == other[1, 2] &&
365+
this[2, 0] == other[2, 0] && this[2, 1] == other[2, 1] && this[2, 2] == other[2, 2]
361366
}

src/main/kotlin/glm_/mat4x4/Mat4.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,5 +540,11 @@ data class Mat4(override var value: MutableList<Vec4>) : Mat4x4t<Vec4>(value) {
540540

541541

542542
override fun toString() = super.toString()
543+
544+
override fun equals(other: Any?) = other is Mat4 &&
545+
this[0, 0] == other[0, 0] && this[0, 1] == other[0, 1] && this[0, 2] == other[0, 2] && this[0, 3] == other[0, 3] &&
546+
this[1, 0] == other[1, 0] && this[1, 1] == other[1, 1] && this[1, 2] == other[1, 2] && this[1, 3] == other[1, 3] &&
547+
this[2, 0] == other[2, 0] && this[2, 1] == other[2, 1] && this[2, 2] == other[2, 2] && this[2, 3] == other[2, 3] &&
548+
this[3, 0] == other[3, 0] && this[3, 1] == other[3, 1] && this[3, 2] == other[3, 2] && this[3, 3] == other[3, 3]
543549
}
544550

src/main/kotlin/glm_/quat/Quat.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,7 @@ class Quat(w: Float, x: Float, y: Float, z: Float) : QuatT<Float>(w, x, y, z) {
187187

188188
override fun toString() = "($w | $x, $y, $z)"
189189

190-
override fun equals(other: Any?) =
191-
if (other is Quat)
192-
this[0] == other[0] && this[1] == other[1] && this[2] == other[2] && this[3] == other[3]
193-
else false
190+
override fun equals(other: Any?) = other is Quat && this[0] == other[0] && this[1] == other[1] && this[2] == other[2] && this[3] == other[3]
194191

195192
@JvmOverloads
196193
fun vectorize(res: Vec4 = Vec4()) = res.put(x, y, z, w)

src/main/kotlin/glm_/quat/QuatD.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,7 @@ class QuatD(w: Double, x: Double, y: Double, z: Double) : QuatT<Double>(w, x, y,
181181

182182
override fun toString() = "($x, $y, $z), $w"
183183

184-
override fun equals(other: Any?) =
185-
if (other is QuatD)
186-
this[0] == other[0] && this[1] == other[1] && this[2] == other[2] && this[3] == other[3]
187-
else false
184+
override fun equals(other: Any?) = other is QuatD && this[0] == other[0] && this[1] == other[1] && this[2] == other[2] && this[3] == other[3]
188185

189186
@JvmOverloads
190187
fun vectorize(res: Vec4d = Vec4d()) = res.put(x, y, z, w)

src/main/kotlin/glm_/vec1/Vec1.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,6 @@ class Vec1(x: Float) : Vec1t<Float>(x) {
124124
@JvmField
125125
val size = length * Float.BYTES
126126
}
127+
128+
override fun equals(other: Any?) = other is Vec1 && this[0] == other[0]
127129
}

src/main/kotlin/glm_/vec1/Vec1b.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,6 @@ class Vec1b(x: Byte) : Vec1t<Byte>(x) {
8585
@JvmField
8686
val size = length * Byte.BYTES
8787
}
88+
89+
override fun equals(other: Any?) = other is Vec1b && this[0] == other[0]
8890
}

src/main/kotlin/glm_/vec1/Vec1i.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,6 @@ class Vec1i(x: Int) : Vec1t<Int>(x) {
106106
@JvmField
107107
val size = length * Int.BYTES
108108
}
109+
110+
override fun equals(other: Any?) = other is Vec1i && this[0] == other[0]
109111
}

0 commit comments

Comments
 (0)