-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslerp.m
62 lines (57 loc) · 1.28 KB
/
slerp.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function out = slerp(p0,p1,t)
% % Syntax;
% %
% % out = slerp(p0,p1,t)
% %
% % ***********************************************************
% %
% % Description
% %
% % program outputs the uniform interpolation of arc defined by p0, p1
% % (around origin).
% %
% % ***********************************************************
% %
% % Input Variables
% %
% % t=0 -> p0, t=1 -> p1.
% %
% % ***********************************************************
% %
% % Output Variables
% %
% % out = interpolated c-ordinates.
% %
% % ***********************************************************
% %
% Example
%
% out = slerp([1,0,0]',[0,1,0]',1)
%
% out =
%
% 0
% 1
% 0
%
% % ***********************************************************
% % List of Sub Programs
%
% % ***********************************************************
% %
% % This program was written by Yogesh G. Phalak
% %
% % date May 2020
% %
% %
% % ***********************************************************
% %
% % Feel free to modify this code.
% %
ang0Cos=scalProd(p0,p1)/scalProd(p0,p0);
ang0Sin=(1-ang0Cos*ang0Cos)^0.5;
ang0 = atan2(ang0Sin,ang0Cos);
l0 = sin((1-t)*ang0);
l1 = sin(t*ang0);
out = (l0*p0+l1*p1)/ang0Sin;
end