quaternionFromTo: Quaternion between two vectors

View source: R/quaternionFromTo.R

quaternionFromToR Documentation

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)

Arguments

u, v

two unit 3D vectors

Value

A unit quaternion whose corresponding rotation transforms u to v.

Examples

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

qsplines documentation built on March 7, 2023, 7:41 p.m.