Generate an Orthogonal Set of Unit Vectors

Given a vector, a set of orthogonal unit vectors is calculated to use as rotated coordinate axes.


Updated 13 Aug 2012

View License

Ex 1:
z_in = [0 0 5]';
[x, y, z] = orthogonal_set(z_in);

Supplied with the z axis, two perpendicular unit vectors are created in the xy plane.

Ex 2:
n = [1 -2 5]';
[x, y, z] = orthogonal_set(n);

Supplied with a normal vector, the returned orthogonal set of unit vectors will have a z vector parallel to the normal and an x and y vector that can be used to describe the plane that has n as a normal.

Test Scripts:

t_orthogonal_set.m - unit test the function and ensure the resulting vectors are a correct orthogonal set

t_show_me.m - A quick script that generates the screenshot image

Cite As

Dan Couture (2023). Generate an Orthogonal Set of Unit Vectors (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Visual Exploration in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes