slerp is not correct
Closed this issue · 2 comments
stla commented
Hello,
I think that seq
with the option slerp = TRUE
is wrong. Look at this example:
> q1
[1]
Re -0.5615167
i -0.2325878
j 0.5615167
k -0.5615167
> q2
[1]
Re -0.5615167
i -0.5615167
j 0.2325878
k -0.5615167
> seq(q1, q2, length.out = 3, slerp = TRUE)
[1] [2] [3]
Re -0.5615167 -0.57735027 -0.5615167
i -0.2325878 -0.04417009 0.1466703
j 0.5615167 0.47071423 0.3540935
k -0.5615167 -0.66569045 -0.7333516
The last element of the sequence is not q2
. That's wrong.
The code is from * (to/from)^h
. It should be from * (Ainv(from)*to)^h
.
RobinHankin commented
You are absolutely correct, thanks. One difficulty is that the idiom in the package seems to work for many simple examples but
> x1 <- 1+Hi
> x2 <- 1+Hi+Hj
> seq(from=x1,to=x2,len=3,slerp=TRUE)
[1] [2] [3]
Re 1 1.0546907 1
i 1 1.0546907 1
j 0 0.0000000 0
k 0 0.4740726 1
> seq(from=x1,to=x2,len=3,slerp=TRUE)[3] - x2
[1]
Re -1.110223e-16
i -1.110223e-16
j -1.000000e+00
k 1.000000e+00
> Mod(seq(from=x1,to=x2,len=3,slerp=TRUE)[3] - x2)
[1] 1.414214
>
I'll patch it when I get a minute, best wishes, Robin
RobinHankin commented
Something wrong:
> x1 <- 1+Hi
> x2 <- 1+Hi+Hj
> seq(from=x1,to=x2,len=3,slerp=TRUE)
Error in is.finite(if (is.character(from)) from <- as.numeric(from) else from) :
default method not implemented for type 'S4'
In addition: Warning message:
In seq.default(from = x1, to = x2, len = 3, slerp = TRUE) :
extra argument ‘slerp’ will be disregarded
>