Align a Vector to Another

Calculates the rotation matrix that aligns a vector to another


Updated 17 Jan 2023

View License

This function calculates rotation matrix that aligns a vector to another.
function R=Rotation(a,b)
a and b are (3*1) vectors
R is (3*3) rotation matrix that aligns vector a to b so that: the normalized vector of b equals R multiplied by the normalized vector of a
Jur van den Berg (, Calculate Rotation Matrix to align Vector A to Vector B in 3d?, URL (version: 2016-09-01):

Cite As

Ayad Al-Rumaithi (2023). Align a Vector to Another (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes