Blender V5.3
gpu_shader_material_vector_rotate.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
9
11{
12 float costheta = cos(angle);
13 float sintheta = sin(angle);
14 float3 r;
15
16 r.x = ((costheta + (1.0f - costheta) * axis.x * axis.x) * p.x) +
17 (((1.0f - costheta) * axis.x * axis.y - axis.z * sintheta) * p.y) +
18 (((1.0f - costheta) * axis.x * axis.z + axis.y * sintheta) * p.z);
19
20 r.y = (((1.0f - costheta) * axis.x * axis.y + axis.z * sintheta) * p.x) +
21 ((costheta + (1.0f - costheta) * axis.y * axis.y) * p.y) +
22 (((1.0f - costheta) * axis.y * axis.z - axis.x * sintheta) * p.z);
23
24 r.z = (((1.0f - costheta) * axis.x * axis.z - axis.y * sintheta) * p.x) +
25 (((1.0f - costheta) * axis.y * axis.z + axis.x * sintheta) * p.y) +
26 ((costheta + (1.0f - costheta) * axis.z * axis.z) * p.z);
27
28 return r;
29}
30
31[[node]]
33 float3 center,
34 float3 axis,
35 float angle,
36 float3 /*rotation*/,
37 float invert,
38 float3 &vec)
39{
40 vec = (length(axis) != 0.0f) ?
41 rotate_around_axis(vector_in - center, normalize(axis), angle * invert) + center :
42 vector_in;
43}
44
45[[node]]
47 float3 center,
48 float3 /*axis*/,
49 float angle,
50 float3 /*rotation*/,
51 float invert,
52 float3 &vec)
53{
54 vec = rotate_around_axis(vector_in - center, float3(1.0f, 0.0f, 0.0f), angle * invert) + center;
55}
56
57[[node]]
59 float3 center,
60 float3 /*axis*/,
61 float angle,
62 float3 /*rotation*/,
63 float invert,
64 float3 &vec)
65{
66 vec = rotate_around_axis(vector_in - center, float3(0.0f, 1.0f, 0.0f), angle * invert) + center;
67}
68
69[[node]]
71 float3 center,
72 float3 /*axis*/,
73 float angle,
74 float3 /*rotation*/,
75 float invert,
76 float3 &vec)
77{
78 vec = rotate_around_axis(vector_in - center, float3(0.0f, 0.0f, 1.0f), angle * invert) + center;
79}
80
81[[node]]
83 float3 center,
84 float3 /*axis*/,
85 float /*angle*/,
86 float3 rotation,
87 float invert,
88 float3 &vec)
89{
90 float3x3 rmat = (invert < 0.0f) ? transpose(from_rotation(EulerXYZ::from_float3(rotation))) :
92 vec = rmat * (vector_in - center) + center;
93}
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
#define sin
#define cos
VecBase< float, D > normalize(VecOp< float, D >) RET
MatBase< R, C > transpose(MatBase< C, R >) RET
float length(VecOp< float, D >) RET
float3 rotate_around_axis(float3 p, float3 axis, float angle)
void node_vector_rotate_axis_x(float3 vector_in, float3 center, float3, float angle, float3, float invert, float3 &vec)
void node_vector_rotate_axis_y(float3 vector_in, float3 center, float3, float angle, float3, float invert, float3 &vec)
void node_vector_rotate_euler_xyz(float3 vector_in, float3 center, float3, float, float3 rotation, float invert, float3 &vec)
void node_vector_rotate_axis_z(float3 vector_in, float3 center, float3, float angle, float3, float invert, float3 &vec)
void node_vector_rotate_axis_angle(float3 vector_in, float3 center, float3 axis, float angle, float3, float invert, float3 &vec)
float2x2 invert(float2x2 mat)
float2x2 from_rotation(AngleRadian rotation)
static EulerXYZ from_float3(float3 eul)
float z
Definition sky_math.h:136
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136