We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5a052e6 commit bce205dCopy full SHA for bce205d
build.gradle
@@ -9,7 +9,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
9
10
buildscript {
11
12
- ext.kotlinVersion = '1.2.20'
+ ext.kotlinVersion = '1.2.21'
13
14
repositories {
15
jcenter() // shadow
@@ -26,7 +26,7 @@ dependencies {
26
27
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
28
29
- compile 'com.github.kotlin-graphics:kotlin-unsigned:v3.0.5'
+ compile 'com.github.kotlin-graphics:kotlin-unsigned:9f1103b13fa5840bafff72a6d40a2d3c9aea5e58'
30
31
testCompile 'io.kotlintest:kotlintest:2.0.7'
32
}
src/main/kotlin/glm_/func/common/func_common.kt
@@ -18,6 +18,7 @@ import glm_.glm.trunc
18
import unsigned.Uint
19
import unsigned.Ulong
20
import kotlin.math.absoluteValue
21
+import kotlin.math.pow
22
import kotlin.math.sign
23
import kotlin.reflect.KMutableProperty0
24
import kotlin.math.ceil as _ceil
@@ -256,7 +257,8 @@ interface func_common {
256
257
258
259
- // TODO ldexp
260
+ fun ldexp(a: Float, exp: Int) = a * 2f.pow(exp)
261
+ fun ldexp(a: Double, exp: Int) = a * 2.0.pow(exp)
262
263
264
src/main/kotlin/glm_/func/common/func_vector1_common.kt
@@ -12,6 +12,7 @@ import glm_.glm.frexp
import glm_.glm.intBitsToFloat
import glm_.glm.isInf
import glm_.glm.isNan
+import glm_.glm.ldexp
16
import glm_.glm.max
17
import glm_.glm.min
import glm_.glm.mix
@@ -510,7 +511,18 @@ interface func_vector1_common {
510
511
512
513
514
+ fun ldexp(a: Vec1, exp: Vec1i) = ldexp(a, exp, Vec1())
515
+ fun ldexp(a: Vec1, exp: Vec1i, res: Vec1): Vec1 {
516
+ res.x = ldexp(a.x, exp.x)
517
+ return res
518
+ }
519
+
520
+ fun ldexp(a: Vec1d, exp: Vec1i) = ldexp(a, exp, Vec1d())
521
+ fun ldexp(a: Vec1d, exp: Vec1i, res: Vec1d): Vec1d {
522
523
524
525
526
527
companion object {
528
var _i = 0 // TODO mention potential multithread issues
src/main/kotlin/glm_/func/common/func_vector2_common.kt
@@ -585,7 +586,20 @@ interface func_vector2_common {
585
586
587
588
589
+ fun ldexp(a: Vec2, exp: Vec2i) = ldexp(a, exp, Vec2())
590
+ fun ldexp(a: Vec2, exp: Vec2i, res: Vec2): Vec2 {
591
592
+ res.y = ldexp(a.y, exp.y)
593
594
595
596
+ fun ldexp(a: Vec2d, exp: Vec2i) = ldexp(a, exp, Vec2d())
597
+ fun ldexp(a: Vec2d, exp: Vec2i, res: Vec2d): Vec2d {
598
599
600
601
602
603
604
605
src/main/kotlin/glm_/func/common/func_vector3_common.kt
@@ -12,6 +12,7 @@ import glm_.glm.fract
@@ -625,7 +626,22 @@ interface func_vector3_common {
625
626
627
628
629
+ fun ldexp(a: Vec3, exp: Vec3i) = ldexp(a, exp, Vec3())
630
+ fun ldexp(a: Vec3, exp: Vec3i, res: Vec3): Vec3 {
631
632
633
+ res.z = ldexp(a.z, exp.z)
634
635
636
637
+ fun ldexp(a: Vec3d, exp: Vec3i) = ldexp(a, exp, Vec3d())
638
+ fun ldexp(a: Vec3d, exp: Vec3i, res: Vec3d): Vec3d {
639
640
641
642
643
644
645
646
647
src/main/kotlin/glm_/func/common/func_vector4_common.kt
@@ -726,7 +727,24 @@ interface func_vector4_common {
726
727
728
729
730
+ fun ldexp(a: Vec4, exp: Vec4i) = ldexp(a, exp, Vec4())
731
+ fun ldexp(a: Vec4, exp: Vec4i, res: Vec4): Vec4 {
732
733
734
735
+ res.w = ldexp(a.w, exp.w)
736
737
738
739
+ fun ldexp(a: Vec4d, exp: Vec4i) = ldexp(a, exp, Vec4d())
740
+ fun ldexp(a: Vec4d, exp: Vec4i, res: Vec4d): Vec4d {
741
742
743
744
745
746
747
748
749
750
src/test/kotlin/glm_/testCoreFunCommon.kt
@@ -731,6 +731,37 @@ class testCoreFunCommon : StringSpec() {
glm.all(glm.equal(exp, Vec4i(10, -2, 0, 1))) shouldBe true
+ "ldexp" {
+ run {
+ val a = Vec1(1)
+ val exp = Vec1i(10)
+ val x = glm.ldexp(a, exp)
+ glm.all(glm.epsilonEqual(x, Vec1(1024),0.00001f)) shouldBe true
+ val a = Vec2(1, 0.96)
+ val exp = Vec2i(10, -2)
+ glm.all(glm.epsilonEqual(x, Vec2(1024, .24),0.00001f)) shouldBe true
751
752
+ val a = Vec3(1, 0.96, 0.0)
753
+ val exp = Vec3i(10, -2, 0)
754
755
+ glm.all(glm.epsilonEqual(x, Vec3(1024, .24, 0),0.00001f)) shouldBe true
756
757
758
759
+ val a = Vec4(1, 0.96, 0.0, -0.665)
760
+ val exp = Vec4i(10, -2, 0, 1)
761
762
+ glm.all(glm.epsilonEqual(x, Vec4(1024, .24, 0, -1.33),0.00001f)) shouldBe true
763
764
765
766
767
0 commit comments