0% found this document useful (0 votes)
12 views2 pages

7

The document provides a series of practical exercises for writing Python programs to perform 3D rotations and reflections of points in space. It includes specific tasks such as rotating the point (1,0,0) through various planes by given angles and reflecting the point (1,2,3) through the XY plane. Additionally, it includes mathematical formulas for rotation and reflection matrices along different axes, along with example code snippets using libraries like numpy and scipy.

Uploaded by

Komal Pokale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

7

The document provides a series of practical exercises for writing Python programs to perform 3D rotations and reflections of points in space. It includes specific tasks such as rotating the point (1,0,0) through various planes by given angles and reflecting the point (1,2,3) through the XY plane. Additionally, it includes mathematical formulas for rotation and reflection matrices along different axes, along with example code snippets using libraries like numpy and scipy.

Uploaded by

Komal Pokale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical 7

1. Write a python program in 3D to rotate the point (1,0,0) through XY plane


in anticlockwise direction (Rotation through Z-axis) by angle of 80 degree.
2. Write a python program in 3D to rotate the point (1,0,0) through XZ plane
in anticlockwise direction (Rotation through Y-axis) by angle of 90 degree.
3. Write a python program in 3D to rotate the point (1,0,0) through XZ plane
in clockwise direction (Rotation through Y-axis) by angle of 90 degree.
4. Write a python program in 3D to rotate the point (1,0,0) through XY plane
in anticlockwise direction (Rotation through Z-axis) by angle of 180 degree.
5. Write a python program in 3D to rotate the point (1,2,3) through YZ plane in
anticlockwise direction (Rotation through X-axis) by angle of 45 degree.
6. Write a python program in 3D to rotate the point (1,2,3) through YZ plane in
anticlockwise direction (Rotation through X-axis) by angle of 60 degree.
7. Write a python program in 3D to reflect the point (1,2,3) through the XY
plane
Rotation along the Z-axis (Rotation in anticlockwise sense)
cos(𝜃) sin(𝜃) 0
𝑅𝑜𝑡𝑧 = − sin(𝜃) cos(𝜃) 0
0 0 1
Rotation along the Y-axis (Rotation in anticlockwise sense)
cos(𝜃) 0 − 𝑠𝑖𝑛(𝜃)
𝑅𝑜𝑡𝑦 = 0 1 0
sin(𝜃) 0 cos(𝜃)
Rotation along the X-axis (Rotation in anticlockwise sense)
1 0 0
𝑅𝑜𝑡𝑥 = 0 𝑐𝑜𝑠(𝜃) 𝑠𝑖𝑛(𝜃)
0 − 𝑠𝑖𝑛(𝜃) cos(𝜃)
Reflection relative to the XY-plane
1 0 0
𝑅𝑒𝑓𝑧 = 0 1 0
0 0 −1
Reflection relative to the YZ-plane
−1 0 0
𝑅𝑒𝑓𝑥 = 0 1 0
0 0 1
Reflection relative to the XY-plane
1 0 0
𝑅𝑒𝑓𝑦 = 0 −1 0
0 0 1
Syntax: Rotation along z axis
import math
import numpy as n
import scipy
from scipy.spatial.transform import Rotation as R
def Rotz(v,theta):
r=math.radians(80)
c,s=n.cos(r),n.sin(r)
A=R.from_matrix([[c,s,0],[-s,c,0],[0,0,1]])
return A.apply(v)

Rotz([1,0,0],80)
Answer:
array([ 0.17364818, -0.98480775, 0. ])
________________________________________________________________
Syntax: Reflection along Z-axis (relative to XY plane)
import math
import numpy as n
import scipy
from scipy.spatial.transform import Rotation as R
def Refz(v):
A=R.from_matrix([[1,0,0],[0,1,0],[0,0,-1]])
return A.apply(v)

Refz([0,0,1])
array([ 0., 0., -1.])

You might also like