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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static quaternion Euler(float x, float y, float z, RotationOrder order = RotationOrder.Default) { return Euler(float3(x, y, z), order); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static quaternion Euler(float3 xyz, RotationOrder order = RotationOrder.ZXY) { switch (order) { case RotationOrder.XYZ: return EulerXYZ(xyz); case RotationOrder.XZY: return EulerXZY(xyz); case RotationOrder.YXZ: return EulerYXZ(xyz); case RotationOrder.YZX: return EulerYZX(xyz); case RotationOrder.ZXY: return EulerZXY(xyz); case RotationOrder.ZYX: return EulerZYX(xyz); default: return quaternion.identity; } }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static quaternion AxisAngle(float3 axis, float angle) { float sina, cosa; math.sincos(0.5f * angle, out sina, out cosa); return quaternion(float4(axis * sina, cosa)); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static quaternion EulerXYZ(float3 xyz) { float3 s, c; sincos(0.5f * xyz, out s, out c); return quaternion( float4(s.xyz, c.x) * c.yxxy * c.zzyz + s.yxxy * s.zzyz * float4(c.xyz, s.x) * float4(-1.0f, 1.0f, -1.0f, 1.0f) ); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static quaternion EulerXZY(float3 xyz) { float3 s, c; sincos(0.5f * xyz, out s, out c); return quaternion( float4(s.xyz, c.x) * c.yxxy * c.zzyz + s.yxxy * s.zzyz * float4(c.xyz, s.x) * float4(1.0f, 1.0f, -1.0f, -1.0f) ); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static quaternion EulerYXZ(float3 xyz) { float3 s, c; sincos(0.5f * xyz, out s, out c); return quaternion( float4(s.xyz, c.x) * c.yxxy * c.zzyz + s.yxxy * s.zzyz * float4(c.xyz, s.x) * float4(-1.0f, 1.0f, 1.0f, -1.0f) ); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static quaternion EulerYZX(float3 xyz) { float3 s, c; sincos(0.5f * xyz, out s, out c); return quaternion( float4(s.xyz, c.x) * c.yxxy * c.zzyz + s.yxxy * s.zzyz * float4(c.xyz, s.x) * float4(-1.0f, -1.0f, 1.0f, 1.0f) ); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static quaternion EulerZXY(float3 xyz) { float3 s, c; sincos(0.5f * xyz, out s, out c); return quaternion( float4(s.xyz, c.x) * c.yxxy * c.zzyz + s.yxxy * s.zzyz * float4(c.xyz, s.x) * float4(1.0f, -1.0f, -1.0f, 1.0f) ); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static quaternion EulerZYX(float3 xyz) { float3 s, c; sincos(0.5f * xyz, out s, out c); return quaternion( float4(s.xyz, c.x) * c.yxxy * c.zzyz + s.yxxy * s.zzyz * float4(c.xyz, s.x) * float4(1.0f, -1.0f, 1.0f, -1.0f) ); }
|