File size: 2,550 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.mojang.math;

import org.joml.Math;
import org.joml.Matrix3f;
import org.joml.Quaternionf;

public record GivensParameters(float sinHalf, float cosHalf) {
    public static GivensParameters fromUnnormalized(float p_276277_, float p_276305_) {
        float f = Math.invsqrt(p_276277_ * p_276277_ + p_276305_ * p_276305_);
        return new GivensParameters(f * p_276277_, f * p_276305_);
    }

    public static GivensParameters fromPositiveAngle(float p_276260_) {
        float f = Math.sin(p_276260_ / 2.0F);
        float f1 = Math.cosFromSin(f, p_276260_ / 2.0F);
        return new GivensParameters(f, f1);
    }

    public GivensParameters inverse() {
        return new GivensParameters(-this.sinHalf, this.cosHalf);
    }

    public Quaternionf aroundX(Quaternionf p_276271_) {
        return p_276271_.set(this.sinHalf, 0.0F, 0.0F, this.cosHalf);
    }

    public Quaternionf aroundY(Quaternionf p_276323_) {
        return p_276323_.set(0.0F, this.sinHalf, 0.0F, this.cosHalf);
    }

    public Quaternionf aroundZ(Quaternionf p_276281_) {
        return p_276281_.set(0.0F, 0.0F, this.sinHalf, this.cosHalf);
    }

    public float cos() {
        return this.cosHalf * this.cosHalf - this.sinHalf * this.sinHalf;
    }

    public float sin() {
        return 2.0F * this.sinHalf * this.cosHalf;
    }

    public Matrix3f aroundX(Matrix3f p_276268_) {
        p_276268_.m01 = 0.0F;
        p_276268_.m02 = 0.0F;
        p_276268_.m10 = 0.0F;
        p_276268_.m20 = 0.0F;
        float f = this.cos();
        float f1 = this.sin();
        p_276268_.m11 = f;
        p_276268_.m22 = f;
        p_276268_.m12 = f1;
        p_276268_.m21 = -f1;
        p_276268_.m00 = 1.0F;
        return p_276268_;
    }

    public Matrix3f aroundY(Matrix3f p_276274_) {
        p_276274_.m01 = 0.0F;
        p_276274_.m10 = 0.0F;
        p_276274_.m12 = 0.0F;
        p_276274_.m21 = 0.0F;
        float f = this.cos();
        float f1 = this.sin();
        p_276274_.m00 = f;
        p_276274_.m22 = f;
        p_276274_.m02 = -f1;
        p_276274_.m20 = f1;
        p_276274_.m11 = 1.0F;
        return p_276274_;
    }

    public Matrix3f aroundZ(Matrix3f p_276317_) {
        p_276317_.m02 = 0.0F;
        p_276317_.m12 = 0.0F;
        p_276317_.m20 = 0.0F;
        p_276317_.m21 = 0.0F;
        float f = this.cos();
        float f1 = this.sin();
        p_276317_.m00 = f;
        p_276317_.m11 = f;
        p_276317_.m01 = f1;
        p_276317_.m10 = -f1;
        p_276317_.m22 = 1.0F;
        return p_276317_;
    }
}