Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vec2::times(Float) #44

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/kotlin/glm_/vec2/Vec2i.kt
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class Vec2i(@JvmField var ofs: Int, @JvmField var array: IntArray) : Vec2t<Int>,


infix operator fun times(b: Int) = times(Vec2i(), this, b, b)
infix operator fun times(b: Float) = times(Vec2i(), this, b, b)
infix operator fun times(b: Vec2i) = times(Vec2i(), this, b.x, b.y)

@JvmOverloads
Expand Down Expand Up @@ -350,6 +351,7 @@ class Vec2i(@JvmField var ofs: Int, @JvmField var array: IntArray) : Vec2t<Int>,

infix operator fun times(b: Number) = times(Vec2i(), this, b.i, b.i)
infix operator fun times(b: Vec2t<out Number>) = times(Vec2i(), this, b._x.i, b._y.i)
infix operator fun times(b: Vec2) = times(Vec2i(), this, b.x, b.y)

@JvmOverloads
fun times(bX: Number, bY: Number, res: Vec2i = Vec2i()) = times(res, this, bX.i, bY.i)
Expand Down
8 changes: 7 additions & 1 deletion src/main/kotlin/glm_/vec2/operators/opVec2i.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ interface opVec2i {
return res
}

fun times(res: Vec2i, a: Vec2i, bX: Float, bY: Float): Vec2i {
res.x = (a.x * bX).toInt()
res.y = (a.y * bY).toInt()
return res
}

fun div(res: Vec2i, a: Vec2i, bX: Int, bY: Int): Vec2i {
res.x = a.x / bX
res.y = a.y / bY
Expand Down Expand Up @@ -149,4 +155,4 @@ infix fun Number.divAssign(b: Vec2i) = div(b, this.i, this.i, b)

infix operator fun Number.rem(b: Vec2i) = rem(Vec2i(), this.i, this.i, b)
fun Number.rem(b: Vec2i, res: Vec2i) = rem(res, b, this.i, this.i)
infix fun Number.remAssign(b: Vec2i) = rem(b, this.i, this.i, b)
infix fun Number.remAssign(b: Vec2i) = rem(b, this.i, this.i, b)
Loading