, pos , new_up.
, pos, . , :
float3 pos;
float3 new_up;
float3 up = float3(0,1,0);
float3 v = cross(up, new_up);
float s = length(v);
float c = dot(up, new_up);
float3x3 VX = float3x3 (
0, -1 * v.z, v.y,
v.z, 0, -1 * v.x,
-1 * v.y, v.x, 0
);
float3x3 I = float3x3 (
1, 0, 0,
0, 1, 0,
0, 0, 1
);
float 3x3 R = I + VX + mul(VX, VX) * (1 - c)/pow(s,2)
float3 new_pos = mul(R, pos);
, new_up .
"target up normal" , R ( ) . . / , , .
pos -4, , ( ).
, , , - , , .