Learn R Programming

qsplines (version 1.0.1)

quaternionFromTo: Quaternion between two vectors

Description

Get a unit quaternion whose corresponding rotation sends u to v; the vectors u and v must be normalized.

Usage

quaternionFromTo(u, v)

Value

A unit quaternion whose corresponding rotation transforms u

to v.

Arguments

u, v

two unit 3D vectors

Examples

Run this code
library(qsplines)
u <- c(1, 1, 1) / sqrt(3)
v <- c(1, 0, 0)
q <- quaternionFromTo(u, v)
rotate(rbind(u), q) # this should be v

Run the code above in your browser using DataLab