0% found this document useful (0 votes)
19 views11 pages

Rubiks Cube2

Report sample

Uploaded by

aditya rijal
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)
19 views11 pages

Rubiks Cube2

Report sample

Uploaded by

aditya rijal
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/ 11

TRIBHUVAN UNIVERSITY

IOE,PULCHOWK CAMPUS

“A REPORT ON RUBIK’S CUBE SIMULATIOR USING PYTHON AND OPENGL"

SUBMITTED BY:
AARBID BHATTARAI (078BCT002)
AAYUSH REGMI(078BCT005)
ADITYA RIJAL (078BCT008)
AWISKAR POKHREL (078BCT023)

SUBMITTED TO:
DEPARTMENT OF ELECTRONICS AND
COMPUTER ENGINEERING

JULY, 2024
Acknowledgement

We would like to express our heartfelt appreciation to our teacher Er. Shanti Tamang Ma’am

and the Department of Electronics and Computer Engineering at the

Institute of Engineering, Pulchowk Campus. They have provided us with an

opportunity to develop this project, which will not only strengthen our

understanding of 2D object and 3D object programming but also enhance our


teamwork

skills.

This project will enable us to apply the theoretical knowledge we have acquired in

Our Computer Graphics. We would like to extend our gratitude

to our professor for continuously motivating us to explore new topics related to

our field of interest.

Throughout the duration of this project, we look forward to receiving your

valuable guidance and feedback. Any suggestions you provide will be highly

appreciated.
Abstract

This project presents a 3D Rubik's Cube simulator developed using Python, Pygame,

and OpenGL. The simulator allows users to interact with a virtual Rubik's Cube,

enabling rotations and standard cube manipulations through keyboard inputs. The

project aims to provide an educational tool for learning Rubik's Cube algorithms

and enhancing visualization skills. The simulator integrates quaternion mathematics

for smooth rotations and uses OpenGL for rendering 3D graphics, offering

immersive experience for users.


3. Table of Contents
1. Acknowledgement 1
2. Abstract 2
3. Table of Contents 3
4. Objectives 4
5. Introduction 4
6. Application 5
7. Methodology 6-7
8. Implementation 12
9. Problems Faced and Solutions 9
10. Limitations and Future Enhancements 9
11. Conclusion 10

Objectives
The main objectives of our project are as follows:

● To apply the concepts of Rotation,Scaling,Translation etc

● To explore different features of Python OpenGL,

● To implement external libraries for Python,

● To understand the dynamics of working in a group,

● To be familiar with git and Github for collaborating on a project in a team,

● To solve a real-world problem.

Introduction
Rubik's Cube is a popular 3D combination puzzle that challenges players to align

faces of the cube to a uniform color. This project aims to create a virtual Rubik's

Cube using Python and OpenGL, allowing users to practice and visualize cube

algorithms in a 3D environment. The project combines computer graphics, game

development, and mathematical concepts to deliver an interactive and educational

application.
Application
The primary application of this project is educational. It serves as a learning tool for

individuals interested in mastering Rubik's Cube algorithms. Additionally, it can be

used for demonstrating computer graphics techniques and the application of

quaternion mathematics in 3D rotations. The simulator can also be extended to

include features for competitive practice and algorithm optimization.


Methodology
Initialization

1. Pygame Setup:
• Initialize the Pygame library for handling the display and user inputs.

• Create an 800x600 window for rendering the 3D cube.

1. OpenGL Setup:
• Configure OpenGL settings, including depth testing and perspective
projection.

• Use gluPerspective for setting the field of view and glTranslatef for
positioning the cube in the scene.

Quaternion Mathematics
• Implement quaternion operations for smooth and accurate 3D rotations.

• Utilize custom functions for quaternion normalization, axis-angle


conversion, and multiplication.

Rendering
• Use OpenGL functions (glBegin, glEnd, glVertex3fv) to draw the
cube's edges and colored faces.

• Implement a draw_stickers function to render the cube's stickers based


on color and position arrays.

Event Handling
• Capture and process keyboard and mouse inputs using Pygame.

• Implement key bindings for rotating the cube and performing standard
Rubik's Cube moves.

Updating and Drawing


• Implement an update function to apply transformations and redraw the
cube.

• Continuously update the display within the main loop, responding to


user inputs in real-time.

Problems Faced and Solutions


Problem 1: Quaternion Rotations

Issue: Implementing accurate and smooth rotations using quaternions was

challenging. Solution: Thorough research and testing of quaternion mathematics

were conducted, leading to the development of reliable quaternion operations for the

project.

Problem 2: Rendering Performance

Issue: Rendering a complex 3D object with multiple moving parts resulted in

performance issues. Solution: Optimized the drawing functions and reduced

unnecessary calculations to improve rendering performance. Utilized OpenGL's

depth testing for efficient rendering.

Problem 3: User Interaction

Issue: Handling multiple user inputs simultaneously and ensuring smooth

interaction. Solution: Implemented robust event handling in Pygame, using non-

blocking techniques to manage user inputs and update the display seamlessly.
Limitations and Future Enhancements

Limitations

• Lack of Scramble Functionality: The scramble function is currently


a placeholder and needs to be fully implemented.

• Limited Move Visualization: The simulator can be enhanced to


visually demonstrate moves step-by-step.

• Basic UI: The user interface is minimal and can be improved for better
usability.

Future Enhancements

• Full Scramble and Solve Algorithms:


Implement scrambling algorithms and provide solving guides or auto-
solve functionality.

• Enhanced User Interface:


Develop a more intuitive and visually appealing user interface with
better control options.

• Mobile Compatibility:
Extend the project to support mobile devices for a broader audience.

• Algorithm Practice Mode:


Introduce a mode for practicing specific algorithms with step-by-step
instructions.
Conclusion
The 3D Rubik's Cube simulator project successfully demonstrates the integration of
Python, Pygame, and OpenGL to create an interactive and educational tool. Despite
certain limitations, the project provides a solid foundation for further enhancements
and serves as a valuable resource for learning Rubik's Cube algorithms and 3D
graphics programming. Future work will focus on addressing the current limitations
and expanding the functionality to enhance user experience and educational value.

You might also like