Create program to display a 2d view of grid-based simulation

Assignment Help Computer Engineering
Reference no: EM131451791

Create a program to display a 2D view of grid-based simulation of gas moving in a flat space. See on-line notes on Gaseous Phenomena. The method for performing simulation of gaseous phenomena is explained in the "Explanation of Gas Simulation Program".

https://www2.cs.uregina.ca/~anima/408/Notes/Gas/index.htm

For your program, you will need to create a graphical display of a grid (large 2D array), by displaying each location as a rectangle of some colour. The colours are used to represent density. Although you may choose your own colouring scheme, the following way of setting the R, G, B colour components gives a nice display where high densities correspond to bright colours.

R = density
G = density * density * 0.05
B = density * density * density * 0.0001

The size of the grid should be controlled by symbolic constants. Initially, try 200 x 200. Each cell in the grid is drawn as a rectangle (GL_QUAD). Use a double ‘for' loop to display 200 x 200 rectangles. It is straightforward to calculate the x and y locations of each rectangle. Use an orthogonal projection, rather than the usual perspective projection, by replacing the gluPerspective command with a
gluOrtho2D(0, WIDTH, 0, HEIGHT);

In your program you should choose some way of representing the current simulation state, which has a current density for each cell and a current (x, y) velocity for each cell. You can use three 2D arrays or one 2D array of structs or classes, or any other way of structuring your data that you want. You will also require an identical set of values for the previous state of the simulation.

To initialize the simulation, set all densities and velocities to zero (0). Every cell should have a 1/20 chance of having some nonzero amount of gas in it. If there is gas, choose a random mass for it between 0 and 100 and random initial velocity, with x and y each between -3.0 and +3.0.

During each simulation step, you will have an old grid and a new grid. Here is a simple approach. Initially set every cell in a new grid to zero. Go through the old grid cell by cell. For each cell, calculate where the given amount of gas (as expressed by its density) should move according to the current velocity recorded for the cell. Update the corresponding four cells in the new grid by changing their densities and velocities. After updating is complete, display the new grid. Then set the old grid to the new grid and repeat. This approach is described in the "Explanation of Gas Simulation Program".notes.

For your program, increase efficiency by avoiding copying the new grid to the old grid at the end of each frame. Instead of doing this copying, you can simply switch which grid you are using for each purpose. One way of doing so is to have two grids in a 2-element array instead of having an old grid and a new grid. For frame i, use grid [i % 2] as the old grid and grid [1 - i % 2] as the new grid.

Creative Feature: Add a creative feature of your choice to your simulation at least 1/5 as large in scope as the above features. Several ideas may result from thinking about which aspects of the users might want to change at runtime.

Reference no: EM131451791

Questions Cloud

Describe the concept of chemical bonds and valence : For instance, from the smoke in this picture we take two small molecule that contain only a single chemical. Describe the concept of chemical bonds and valence.
Explain tammy resistance : Tammy Reinhold didn't believe the rumours. Now that the rumours were confirmed, she was in denial. "I can't believe it," she said.
What role does social media play in your life : What role does social media play in your life? Are you aware of the social media policies of the organizations where you work, attend school, or volunteer?
How much would you request for your meal reimbursements : Your company policy on reimbursement for meals while travelling on company business is that you will be repaid for your out-of-pocket costs.
Create program to display a 2d view of grid-based simulation : CS408 Assignment 5 - Create a program to display a 2D view of grid-based simulation of gas moving in a flat space. See on-line notes on Gaseous Phenomena.
Would government subsidies apply to your type of program : What, specifically, the funding source is (e.g., If it's a government subsidy, from what specific agency might your child development center derive funds?)
Make contact with the individual with the goal of persuading : You have discovered that one of your closest friends at work has stolen a large sum of money from the company. Would you do nothing?
Select the total number of shippers for orders : Select the total number of Shippers for Orders (Hint: use COUNT(ShipVia) as TotalProducts to return non-null counts.
Briefly describe the segmentation and targeting process : Segmentation & targeting-Briefly describe the segmentation and targeting process, acknowledging its relevance to B2C and B2B marketing

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd