You are on page 1of 5

Scanned with CamScanner

Scanned with CamScanner


DIGITAL ASSIGNMENT 1

MATLAB CODE :

clc
clear all
o=[0 0 0];
m=[0.1 -0.2 -0.1];
n=[-0.2 0.1 0.3];
p=[0.4 0 0.1];
rom=m-o;
ron=n-o;
rop=p-o;
rnm=rom-ron
rpm=rom-rop
rpmdotrnm=dot(rpm,rnm)
rpmdotrpm=dot(rpm,rpm)
projrnmonrpm=(rpmdotrnm/rpmdotrpm)*rpm
m1=norm(rnm);
m2=norm(rpm);
costheta=(rpmdotrnm)/(m1*m2)
theta=acos(costheta)
angleInDegrees = rad2deg(theta)

OUTPUT :

rnm =

0.3000 -0.3000 -0.4000

rpm =
-0.3000 -0.2000 -0.2000

rpmdotrnm =

0.0500

rpmdotrpm =

0.1700

projrnmonrpm =

-0.0882 -0.0588 -0.0588

costheta =

0.2080

theta =

1.3613

angleInDegrees =
77.9964

You might also like