- Linear Transformation Simulation on 2D and 3D plane using python OpenGL.
- Developed as part of IF2123 Geometry Algebraic course on Bandung Institute of Technology.
- Submitted on November 18th, 2018.
Execute Main Program:
python main/src/main.py
Also available 3D demo only:
python demo/demo3d.py
\
Running the Program:
- Open the terminal.
- Navigate to the directory where the file is stored.
- Run the file by typing
python3 main.py
. - After that, the user will be prompted to input:
- Type 1 to enter the 3D window.
- Type 2 to enter the 2D window.
- Once the input is entered, the program will display a Pygame or PyOpenGL window.
If the User Chooses 1 (3D):
- To enlarge the screen, press
Page Down
. - To reduce the screen size, press
Page Up
. - To adjust the viewing angle, use arrow keys (up, down, right, left).
- To input a transformation function, press
F
while in the Pygame window. - Then type the function (e.g.,
translate 3 3 3
). - To reset the object, type
reset
.
If the User Chooses 2 (2D):
- To enlarge the screen, press the up arrow key.
- To reduce the screen size, press
Page Up
. - To input a transformation function, press
F
while in the PyOpenGL window. - Then type the function (e.g.,
translate 3 3
). - To reset the object, type
reset
.
Command | Description |
---|---|
translate <dx> <dy> |
Translates the object by shifting the x-value by dx and the y-value by dy . |
dilate <k> |
Performs dilation on the object with a scaling factor of k . |
rotate <deg> <a> <b> |
Rotates the object counterclockwise by deg degrees around the point a,b . |
reflect <param> |
Performs reflection on the object. param can be one of the following values: x , y , y=x , y=-x , or (a,b) . The (a,b) value represents the point for reflection. |
shear <param> <k> |
Performs shear operation on the object. param can be x (along the x-axis) or y (along the y-axis). k is the shear factor. |
stretch <param> <k> |
Performs stretch operation on the object. param can be x (along the x-axis) or y (along the y-axis). k is the stretch factor. |
custom <a> <b> <c> <d> |
Performs a linear transformation on the object using the transformation matrix: [[a b], [c d]] . |
multiple <n> |
Performs linear transformation on the object n times sequentially. Each input line (1..n) can be translate , rotate , shear , etc., excluding multiple , reset , and exit . |
reset |
Resets the object to its initial state. |
exit |
Exits the program. |