summary refs log tree commit diff stats
path: root/src/main/kotlin/space/autistic/radio/complex
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/space/autistic/radio/complex')
-rw-r--r--src/main/kotlin/space/autistic/radio/complex/Complex.kt32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/kotlin/space/autistic/radio/complex/Complex.kt b/src/main/kotlin/space/autistic/radio/complex/Complex.kt
new file mode 100644
index 0000000..918dac2
--- /dev/null
+++ b/src/main/kotlin/space/autistic/radio/complex/Complex.kt
@@ -0,0 +1,32 @@
+package space.autistic.radio.complex
+
+import org.joml.Vector2f
+import org.joml.Vector2fc
+
+fun Vector2f.cmul(v: Vector2fc): Vector2f {
+    return this.cmul(v, this)
+}
+
+fun Vector2f.cmul(v: Vector2fc, dest: Vector2f): Vector2f {
+    val a = this.x * v.x()
+    val b = this.y * v.y()
+    val c = (this.x() + this.y()) * (v.x() + v.y())
+    val x = a - b
+    val y = c - a - b
+    dest.x = x
+    dest.y = y
+    return dest
+}
+
+fun Vector2f.conjugate(): Vector2f {
+    return this.conjugate(this)
+}
+
+fun Vector2f.conjugate(dest: Vector2f): Vector2f {
+    dest.x = this.x()
+    dest.y = -this.y()
+    return dest
+}
+
+val I
+    get() = Vector2f(0f, 1f)
\ No newline at end of file