Mathematics Based OOP Project Ideas

  • Thread starter NotGauss
  • Start date
  • #1
8
5

Summary:

Looking for ideas for a programming project in C++ using OOP

Main Question or Discussion Point

Hello all,
I am currently taking the first of a two semester sequence of C++ courses and I am taking the course as an Honors option and thus I will be writing an extra program to fulfill the requirements.

A little about my experience, I am currently taking Calc 3 and an intro to proves math course and have experience with procedural programming. Last semester for Calc II, I wrote a programming to numerical integrate polynomials with Simpsons and the trapezoidal rule.

This semester I would again like my program to be math (I am a math major) based but I am having a difficult time coming up with ideas that fit into the OOP programming style.

Unfortunately, my meeting with my professor was canceled today due to poor weather and I won’t be able to have a face to face for another couple of weeks to talk ideas.

My main issue is that my project is required to be in OOP style and I just haven’t had enough experience to relate ideas into the OOP style and I haven’t came across anything decent in google searches.

Any ideas, recommendations, or advice would be greatly appreciated.

Jonathan.
 

Answers and Replies

  • #2
11,794
5,402
When you think OOP, think objects first. Any given object will have various attributes that describe its state and methods that either change the state or tell what the state or compute some value from the attributes.

in geometry, you have various shapes like triangles, rectangles and circles. In physics, you could use OOP for a planetary system like our solar system or the three body problem where the objects are the sun, planets, moons and asteroids.
In a strategy game, the objects would be the pieces and perhaps the board upon which they sit.

what programming language were you planning to use? (Oops got it C++)

Khan Academy can help you get up to speed on OOP

https://www.khanacademy.org/computi...g/programming/object-oriented/pt/object-types
 
  • Like
Likes sysprog and FactChecker
  • #3
DaveC426913
Gold Member
18,776
2,256
Make a Solar system simulator or simple orbital simulator.

Works great for OOP, as each orbiting body is an object that handles its own machinations.

I made one in Java where you could add planets freely just by clicking on a location and then dragging to add a velocity vector.

I spent hours trying to see if I could set up a moon orbiting a planet orbiting a sun.
 
  • Like
Likes pbuk
  • #4
11,794
5,402
There are three body simulations that show semi stable orbits if the position, velocity are setup correctly.
 
  • #5
8
5
Ok, thank you all for the ideas! I’ll start looking into these.
 
  • Like
Likes jedishrfu
  • #6
Dr Transport
Science Advisor
Gold Member
2,371
497
Ray tracing is conducive to OOP
 
  • Like
Likes jedishrfu
  • #7
.Scott
Homework Helper
2,534
912
I'm not sure "think objects first" is good advice. Better to "think objects soon".
Nor would I subscribe to the notion that there are specific application that are more suited to OO than others. OO can be applied to any project - and except for the most trivial once-off code, I recommend it for any project.

So here's my suggestion:
1) Requirements: Decide what you want this software to do. Be careful not to bite off more than you are willing to tackle. This project will almost certainly consume more of your time than you expect.
2) Design - Think Data [Processing]: Data and Processing are a single notion - but to get the design process rolling, it is usually best to try to envision the processing while enumerating and organizing the data elements. Just as an example, let's say you want to play around with the color mapping problem. So there is an overall bounded map surface - use a rectangular area, so we have min/max x and y - and perhaps a map name to include on reports. Then we will have vertices (list of x and y) and a list of connections (pairs of vertices pointers or references) that form the polygons to be colored. We will also need to be able to draw a line segment from one of these vertices to the North/South/East of West edge of the map - so we might be thinking that four vertices reference values might be reserved for those compass direction. As the data is processed, we will generate a list of polygons and another list that shows what polygons bound what other polygons. Will each polygon have its own list of other polygons that it touches - or will there be a single "touch list" with references to a polygon list? It depends on exactly what we will be doing.
You probably will never put all of this data into a formal database, but you can still apply some database design methods to it. I am specifically thinking of "normalization" - the notion that every field in a database record should describe the key, the whole key, and nothing but the key, so help me Codd. [a reference to Boyce-Codd normalization].
So, at this point in the design for the example above, we may be thinking of these potential objects:
a) map surface - probably no "key" since we will only work with one at a time - described by a name (character string), four floating point min/max limits, and perhaps pointers or references to its contents - although those may also be single-instance objects.
b) vertices, the list - there is only one list, so no key is needed - we may want to include the number of items and we are probably going to keep the list in memory. The exact implementation will depend on the "processing" part of the design - such as how we the polygons are going to be specified. This may be a simple array.
c) vertices - since polygons will be lists of vertices, each vertex must have a key. Perhaps just an index. - the vertex structure itself is just an X/Y coordinate.
d) Polygons, the list - there is only one list of polgony, so ....

you get the idea.

3) Design - Think [Data] Processing: Now walk through how the data will be processed. Perhaps we have a text file that lists the coordinates of the polygons (thus maybe a text file reading object). So as we read the list in, we will need to match up matching vertices and edges (sounds like a member function of the map object). We will be performing checks - except for the map edge, every pair of vertices must be included in zero or two polygons. At some point we will have the topology side (list of polygons that point to the polygons they touch) and the graphics side (that includes the x/y coordinates). The actual color assignment would be a member function of the polygon list.

4) Implementation: As you write the code, you will refine the design. You will discover ways to break up functions into pieces that can be member functions of the lower level objects. You may discover that there are already libraries for printing your map to paper or screen - and that the interface to those libraries require specific structure changes to your object design. Also, bear in mind that the normalization process I described earlier is a design exercise. When it comes to implementation, it is entirely fair play to denormalize in situation where the data redundancy is not the primary issue.
 
  • Like
Likes sysprog and NotGauss
  • #8
11,794
5,402
Writing your first OOP program can be daunting. There are many online resources to teach you how to do it. Here's one I found recently that explains OO design:

https://codeburst.io/how-to-do-object-oriented-programming-the-right-way-1339c1a25286

In my experience for newbies, if you find a problem that has clearly defined physical objects then it becomes easier to write an OO program. The trick is in identifying the objects at the start.

In the early days of OO, a sports team analogy was used to describe object and message passing. Each team player (object) acts independently but in coordination with other players passing visual cues (messages) back and forth between themselves with the end goal of scoring a goal. The field might be considered the program or another object which keeps track of player positions (or the player object could do that // decisions you need to make in your design).

In the OO design, your objects will also pass messages among themselves with each object knowing how to do a portion of the work.

Model View Controller

A popular OO program design template is the Model-View-Controller where you have a model that does computations, and a view that displays those computations and a controller that takes user input passes it to the model or to the view. When the user input changes the view, the view asks the model for information to display. When the user input changes the model, the model notifies the view that a change has been made and the view then asks the model for new information to display.

All these interactions, are messages passed between the model, the view and the controller. The view doesn't know how to compute anything and the model doesn't know how to display anything. There's a clear separation of responsibility between them.

Design-wise this makes it easier to replace the model with a newer model without having to change the view code or changing the view to a newer fancier view without having to change the model.

https://en.wikipedia.org/wiki/Model–view–controller

 
  • Like
  • Informative
Likes QuantumQuest, Klystron and NotGauss
  • #9
Stephen Tashi
Science Advisor
7,160
1,314
The most natural academic demonstration of OOP applied to mathematics would involve creating an object to represent a general mathematical structure (such as a monoid) and then, by inheritance, create specialized versions of this structure ( such as semigroup, group, ring). A main argument in favor of OOP is the re-usability of code. If you think of traditional programming, it's natural to think of a program that accompishes a certain task. For OOP, it's better to think of writing a "library" that can be used in various programs even though your project may only require one program that does a single task.
 
  • Like
  • Informative
Likes sysprog, NotGauss and Klystron
  • #10
8
5
The most natural academic demonstration of OOP applied to mathematics would involve creating an object to represent a general mathematical structure (such as a monoid) and then, by inheritance, create specialized versions of this structure ( such as semigroup, group, ring). A main argument in favor of OOP is the re-usability of code. If you think of traditional programming, it's natural to think of a program that accompishes a certain task. For OOP, it's better to think of writing a "library" that can be used in various programs even though your project may only require one program that does a single task.
Just got done reading a wiki on monoids, and I think this is something I would like to pursue for my project. Some (probably more than I think) of the material is over my head, can you recommend a text or video series on the subject?

Thanks!
 
  • #11
Stephen Tashi
Science Advisor
7,160
1,314
Just got done reading a wiki on monoids, and I think this is something I would like to pursue for my project. Some (probably more than I think) of the material is over my head, can you recommend a text or video series on the subject?
Keep in mind that my advice is based what is useful to a math major and also a clear academic illustration of understanding OOP to a professor grading the project. If the project will be evaluated by somone who prefers to see image processing etc, you'd be better off doing something along those lines.

The general subject that deals with structures like those presented in the wiki article on Monoid is "abstract algebra". I'm unfamiliar with modern textbooks. The books on abstract algebra that I used 30 years ago did not follow the diagram shown in the wikipdedia article on Monoid. The undergraduate texts began with vector spaces. The graduate texts began with Group Theory and proceeded to Rings. The attitude of the instructors was that things with less structure than a group weren't interesting. In my day, abstract algebra courses taught in the math department did not employ computers or Computer Algebra System (CAS) software.

If your professor likes abstract algebra, he might be enthusiastic about a project based on it. However, if you haven't taken courses in abstract algebra, you will need detailed guidance. If the professor is too busy to give this guidance, pick mathematical structures that are already familiar to you. You mentioned polynomials. One can consider polynomials to various levels of abstraction. The coefficients of a polynomial are elements of a "field". The field can be the real numbers, the complex numbers, a finite field (such as arithmetic modulo 7). A polynomial in one variable be considered as symbolic expressions- a string involving the symbol "X". Such a "class" can be the parent of polynomials where the variable represents a real number, or a complex number, or a matrix, or an element of a finite field.

If you have studied vector spaces from an advanced point of view, you may be familiar with the idea of vector spaces (specifically inner product spaces) of functions. Examples of this are vector spaces of orthogonal polynomials, which can be subclassed into examples like the Chebyshev polynomials. If you aren't familiar with the abstract notion of an inner product space, you might be able to read presentations of various types of orthogonal polynomials and notice common patterns. (A ten second introduction to this: Pick a "kernel" function ##k(x)## and an interval ##[a,b]## and define the inner product of two polynomials ##f(x),g(x)## to be ##\int_a^b f(x) g(x) k(x) dx##. Arrange things so this inner product behaves like the dot product of two vectors. Study sets of polynomials that are orthogonal with respect to the inner product.)

If do you end up "on the ground floor" of abstract algebra. The most significant result in semigroups is called, by engineers, the Krohn-Rhodes decomposition theorem.. Perhaps a presentation of that idea from the engineering point of view would be simpler to understand than the math department's version of it.
 
  • Like
Likes sysprog, NotGauss and Klystron

Related Threads on Mathematics Based OOP Project Ideas

  • Last Post
Replies
2
Views
1K
Replies
5
Views
655
  • Last Post
Replies
6
Views
2K
  • Last Post
Replies
11
Views
3K
  • Last Post
Replies
2
Views
4K
Replies
24
Views
2K
  • Last Post
Replies
15
Views
7K
  • Last Post
Replies
8
Views
2K
  • Last Post
Replies
1
Views
4K
  • Last Post
Replies
3
Views
2K
Top