forked from iff-gsc/LADAC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquatSlerp.m
39 lines (35 loc) · 1.18 KB
/
quatSlerp.m
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
function [q_out] = quatSlerp(p, q, t)
% quatSlerp calculates spherical linear interpolation
% q_out = quatMultiply( q ) computes spherical linear interpolation of
% two quaternions in the form of [w; x; y; z]. With the scalar part w and
% vector parts x, y and z. The scalar parameter t is the interpolation
% coefficient in the range [0, 1].
%
% Syntax:
% q_out = quatMultiply( p, q, t )
%
% Inputs:
% p first quaternion (4x1 array), dimensionless
% q second quaternion (4x1 array), dimensionless
% t interpolation coefficient (scalar), dimensionless
%
% Outputs:
% q_out result of slerp (4x1 array), dimensionless
%
% Example:
% p = [0.7071; 0.7071; 0; 0];
% q = [0.7071; -0.7071; 0; 0];
% t = 0.5;
% q_out = quatMultiply(q, qr, t)
%
% See also:
% quatDivide, quatInv, quatNorm
%
% Disclamer:
% SPDX-License-Identifier: GPL-3.0-only
%
% Copyright (C) 2020-2022 Fabian Guecker
% Copyright (C) 2022 TU Braunschweig, Institute of Flight Guidance
% *************************************************************************
q_out = quatMultiply(quatPower(quatMultiply(q, quatInv(p)), t), p);
end