2D cross product
This commit is contained in:
parent
a6abc783b4
commit
16666055ba
@ -4,7 +4,7 @@ kotlin.code.style=official
|
|||||||
specifyKotlinAsDependency=false
|
specifyKotlinAsDependency=false
|
||||||
|
|
||||||
projectGroup=ru.dbotthepony.kommons
|
projectGroup=ru.dbotthepony.kommons
|
||||||
projectVersion=2.9.15
|
projectVersion=2.9.16
|
||||||
|
|
||||||
guavaDepVersion=33.0.0
|
guavaDepVersion=33.0.0
|
||||||
gsonDepVersion=2.8.9
|
gsonDepVersion=2.8.9
|
||||||
|
@ -111,6 +111,27 @@ data class Vector2d(
|
|||||||
|
|
||||||
operator fun unaryMinus(): Vector2d = Vector2d(-x, -y)
|
operator fun unaryMinus(): Vector2d = Vector2d(-x, -y)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2D vector cross product (Z coordinate)
|
||||||
|
*/
|
||||||
|
fun cross(other: IStruct2d): Double {
|
||||||
|
return x * other.component2() - other.component1() * y
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2D vector cross product (Z coordinate)
|
||||||
|
*/
|
||||||
|
fun cross(other: IStruct2f): Double {
|
||||||
|
return x * other.component2() - other.component1() * y
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2D vector cross product (Z coordinate)
|
||||||
|
*/
|
||||||
|
fun cross(other: IStruct2i): Double {
|
||||||
|
return x * other.component2() - other.component1() * y
|
||||||
|
}
|
||||||
|
|
||||||
fun dot(x: Double, y: Double) = this.x * x + this.y * y
|
fun dot(x: Double, y: Double) = this.x * x + this.y * y
|
||||||
fun dot(value: IStruct2d): Double { val (x, y) = value; return dot(x, y) }
|
fun dot(value: IStruct2d): Double { val (x, y) = value; return dot(x, y) }
|
||||||
fun dot(value: Vector2d): Double { val (x, y) = value; return dot(x, y) }
|
fun dot(value: Vector2d): Double { val (x, y) = value; return dot(x, y) }
|
||||||
|
@ -111,6 +111,27 @@ data class Vector2f(
|
|||||||
|
|
||||||
operator fun unaryMinus(): Vector2f = Vector2f(-x, -y)
|
operator fun unaryMinus(): Vector2f = Vector2f(-x, -y)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2D vector cross product (Z coordinate)
|
||||||
|
*/
|
||||||
|
fun cross(other: IStruct2f): Float {
|
||||||
|
return x * other.component2() - other.component1() * y
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2D vector cross product (Z coordinate)
|
||||||
|
*/
|
||||||
|
fun cross(other: IStruct2i): Float {
|
||||||
|
return x * other.component2() - other.component1() * y
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2D vector cross product (Z coordinate)
|
||||||
|
*/
|
||||||
|
fun cross(other: IStruct2d): Double {
|
||||||
|
return x * other.component2() - other.component1() * y
|
||||||
|
}
|
||||||
|
|
||||||
fun dot(x: Float, y: Float) = this.x * x + this.y * y
|
fun dot(x: Float, y: Float) = this.x * x + this.y * y
|
||||||
fun dot(value: IStruct2f): Float { val (x, y) = value; return dot(x, y) }
|
fun dot(value: IStruct2f): Float { val (x, y) = value; return dot(x, y) }
|
||||||
fun dot(value: Vector2f): Float { val (x, y) = value; return dot(x, y) }
|
fun dot(value: Vector2f): Float { val (x, y) = value; return dot(x, y) }
|
||||||
|
@ -88,6 +88,27 @@ data class Vector2i(
|
|||||||
|
|
||||||
operator fun unaryMinus(): Vector2i = Vector2i(-x, -y)
|
operator fun unaryMinus(): Vector2i = Vector2i(-x, -y)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2D vector cross product (Z coordinate)
|
||||||
|
*/
|
||||||
|
fun cross(other: IStruct2f): Float {
|
||||||
|
return x * other.component2() - other.component1() * y
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2D vector cross product (Z coordinate)
|
||||||
|
*/
|
||||||
|
fun cross(other: IStruct2i): Int {
|
||||||
|
return x * other.component2() - other.component1() * y
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2D vector cross product (Z coordinate)
|
||||||
|
*/
|
||||||
|
fun cross(other: IStruct2d): Double {
|
||||||
|
return x * other.component2() - other.component1() * y
|
||||||
|
}
|
||||||
|
|
||||||
fun dot(x: Int, y: Int) = this.x * x + this.y * y
|
fun dot(x: Int, y: Int) = this.x * x + this.y * y
|
||||||
fun dot(value: IStruct2i): Int { val (x, y) = value; return dot(x, y) }
|
fun dot(value: IStruct2i): Int { val (x, y) = value; return dot(x, y) }
|
||||||
fun dot(value: Vector2i): Int { val (x, y) = value; return dot(x, y) }
|
fun dot(value: Vector2i): Int { val (x, y) = value; return dot(x, y) }
|
||||||
|
Loading…
Reference in New Issue
Block a user