5CCGD002W Applied Maths and Physics for Games Coursework


5CCGD002W Applied Maths and Physics for Games Coursework 2 – Physics Engine (2020-21) referred deferred version21) – ref def
Module leader Philip Trwoga
Unit Coursework
Weighting: 70%
Qualifying mark 30%
Description Demonstration of Vector Math and Physics Principles in Unity
Learning Outcomes Covered in this Assignment: LO1 Demonstrate an understanding of the physics required in a given application scenario to external forces and the laws of motion including conservation of momentum and friction;
LO2 Demonstrate an understanding of the physics required in a given application scenario including rotational mechanics and gravity;
Handed Out: 14th June 2021
Due Date 8th July 2021 by 1pm on Blackboard
Expected deliverables Complete solution for engine – zipped file – Unity (note that a solution in Unreal will not be accepted) – viva and demonstration (compulsory)
Referred Version only: Improvements to Solution Document – see notes
Method of Submission: Online only via Blackboard
Type of Feedback and Due Date:
Generic feedback will be provided during tutorial sessions and lectures. Verbal feedback on the submitted CW will be provided during the CW presentation/viva and also in the Blackboard rubric. Feedback is due by the 21st July 2021.
Note: All marks will remain provisional until formally agreed by an Assessment Board.
BCS CRITERIA MEETING IN THIS ASSIGNMENT 2.1.1 Knowledge and understanding of facts, concepts, principles & theories
2.1.3 Problem solving strategies
3.1.4 Knowledge and understanding of mathematical and/or statistical principles
Assessment regulations
Refer to section 4 of the “How you study” guide for undergraduate students for a clarification of how you are assessed, penalties and late submissions, what constitutes plagiarism etc.
Penalty for Late Submission
If you submit your coursework late but within 24 hours or one working day of the specified deadline, 10 marks will be deducted from the final mark, as a penalty for late submission, except for work which obtains a mark in the range 40 – 49%, in which case the mark will be capped at the pass mark (40%). If you submit your coursework more than 24 hours or more than one working day after the specified deadline you will be given a mark of zero for the work in question unless a claim of Mitigating Circumstances has been submitted and accepted as valid.
It is recognised that on occasion, illness or a personal crisis can mean that you fail to submit a piece of work on time. In such cases you must inform the Campus Office in writing on a mitigating circumstances form, giving the reason for your late or non-submission. You must provide relevant documentary evidence with the form. This information will be reported to the relevant Assessment Board that will decide whether the mark of zero shall stand. For more detailed information regarding University Assessment Regulations, please refer to the following website:http://www.westminster.ac.uk/study/current-students/resources/academic-regulations
Note: By submitting the work through Blackboard you are acknowledging that this is solely your own work. Any code which is not created by you MUST be clearly commented as such. Any code discovered to not have been created by you will mean that the work will be submitted to academic standards for a potential assessment offence, which may result in a zero mark in the component or whole module. Work will be submitted to SafeAssign for in order to check for plagiarism and collusion.
IMPORTANT NOTES: For the referred assessment you must write a short document (1 side of A4 max) which highlights how you have improved your solution from your original submission. Name the document ‘Improvements to Solution Document’ and zip together with your XCode project file.
Note that you that all solutions must be your own work and the viva is compulsory it which you will be required to fully explain your solution. Work marked without a viva (unless it is specified that a viva is not required) will receive a maximum mark of 30%.
Applied Maths and Physics for Games – Coursework 2 Specification and Mark Scheme
Motion Physics for typical Game Scenarios
Introduction
You are to build a small set of 3D physics demonstrations using the Unity Game Engine that can perform a variety of tasks in 3D using vector maths and equation of motion . This can be implemented in the language of your choice (Javascript or C#) though C# is preferred. Note that you are allowed to use the transform of all the game objects but not the rigid body or any of the Unity Physics. You must use the Euler method (described in the lectures) for all of the problems. You can use the structure Vector but not its methods such as normalized etc. Note that for high marks your solutions must be complete (meet all requirements), well coded, reusable, be a realistic, and take into account the dimension of the game objects in collisions. See the grade descriptors in this document.
Note that any mathematical symbols in bold are vector quantities.
Task 1:
Vector Maths – 25 Marks available
You shall build and test a class library consisting of at least the following functions. Note in Unity you can use Vector3 as your basic 3D vector structure. See Appendix A.
Function Max Mark3 %
3D vector addition 2
3D vector subtraction 2
3D dot product 2
Unit vector of a 3D vector 2
Vector reflection (axis aligned) 2
Polar to cartesian, Cartesian to Polar coordinates 3
Unit direction vector4 2
Magnitude of a 3D vector 2
Scaler multiple of 3D vector 2
Vectors nearly equal with radius 2
3D zero vector (0,0,0) 2
A point is on a line 2
Important Note: you should include at least one test for all these functions to get full marks in this section to demonstrate correctness in the functionality. Create a separate test script with hard coded test cases you can also use any built-in unit testing tools. Note you can use Debug.Log(…) to print your tests to the console.
Also note you may choose to create more methods such as vector projection in order to help you solve the problems.
Solve the following time- stepping problems using the Euler or similar method (see Appendix C) using your vector maths library:
Task 2 – 10 Marks available – 3D Trajectory problem with restitution
A) A trajectory in 3D (use a sphere) for a projectile that has a launch vector that can be set in design time. Time step = Time.deltaTime. The gravity vector is (0.0, -9.81,0.0). The initial position of the projectile can be anywhere in your scene. When the sphere lands (so y component of position very close to zero) then the sphere should bounce as though on a hard surface. See figure 1. Use a coefficient of restitution e that has a value that can be set at design time by using a public property on the script. Note that you need to decide when to stop the ball and this should be when the new bounce height (in y) is approaching zero. In other words, the vertical velocity after the bounce is smaller in than some tolerance (e.g. 0.01).
Figure 1 Ball in motion for 3D trajectory
Figure 2 Velocity setting
Figure 3 Showing entry for restitution (bounciness)
Task 3 – 15 Marks Available
This task is to create a scene that demonstrates a path follow routine using vector maths (direction vectors). Set up four or more game objects (waypoints) anywhere in a 3D scene. Another game object (a sphere) travels from waypoint to waypoint continuously at a speed that can be set via a public property in the Unity script. Once the sphere is within a given distance to the waypoint, it should then move in a circle around the waypoint and then on to the next waypoint (5 points for this step). The radius of the rotation can be set as a public property – see Figure 5 Waypoint script settings.
If your waypoints are labelled A B C D, then the order of travel shall be A B C D A and then repeat. The figure below shows an example scene with four cylinders as waypoints. Note that you must be able to move the waypoints to any location at design time and path follow with still work. Figure 6 shows the moving object’s public script properties.
Figure 4 Waypoint scene
Figure 5 Waypoint script settings
Task 4: – 25 Marks Available
A) Vector reflection and friction problem. Construct a plane surround by four solid walls. This is similar to the pool or snooker table and can be square or rectangular. Figure 6 show a stylised plane and four cubes stretched out to form the surrounding walls (think snooker table cushions to get the dimensions correct). For part A you only need one ball (sphere).
Note that it is very important that the ‘table’ is aligned with the x-z plane exactly so that the boundaries and axis-aligned so that you can use simple axis-aligned vector reflection. Note that this is essentially a 2D problem and the y-component is not needed for the calculations (though is used to position the sphere on that table when designing).
For the first part of the problem, you need to demonstrate axis-aligned vector reflection from the boundaries. To do this set up a sphere on the plane that can be assigned an initial velocity (z and x components only actually change). When the sphere hits a boundary, it should ‘reflect’ of both the vertical and horizontal boundaries realistically (angle of incidence = angle of reflection). To slow the ball down you need to add dynamic friction to the table which is a decelerating force, and this is the acceleration part of the problem (as the mass of spheres in the problem all equal 1). The friction factor can be varied at design time (see Figure 6) and friction is always acting as a force (so deceleration) in the opposite direction of the sphere’s velocity vector. In other words, to create the deceleration vector you need to get the unit direction vector of the sphere velocity, reverse it, and then scale that by the friction factor.
Figure 6 Properties for the ball showing velocity setting and friction factor
Figure 7 Textured scene for the vector reflection problem
B) Extension to Task 3. – Maximum of 25 marks for handling the first impact and the case of collisions between two moving balls (15 marks if only the first collision is handled) – see Appendix D for the formula for this.
You are to implement a two-ball collision at an arbitrary angle. Considering the scene in Figure 7 for the initial impact of the stationary red/target ball and cue ball, we have a white ball and red ball set up on the table. Using the code already created for part A, we can direct the white ball towards the red ball in the scene and because we control the initial velocity, we can hit the red ball at any angle. On collision the subsequent velocity vectors are dictated by the conservation of momentum a shown below. Note you can assume that the ball masses are equal so ??1 = ??2 and for the simple case that ???? = ??. You can also assume that all collisions are perfectly elastic. For full marks you need to handle the first impact (cue ball onto target ball) and secondary impacts of the balls even if both are moving, and in both cases you need to move both balls (update the positions) after any collision with side until the balls come to rest. Both balls should bounce realistically if they strike the boundaries after the impact.
2D conservation of momentum problem for an elastic collision at an angle.
???????? + ???????? = ???????? + ????????
Where ???? ???? and ???? ???? are the masses and initial velocities of the system and ????and ???? are the final velocities of the system. Again, the y-component for the velocities is always zero as we are only considering motion in the x-z plane.
Note as the masses are the same, we have the vector relationship of:
???? = ???? + ????
and by consideration of the conservation of kinetic energy (perfectly elastic collision) when the masses are equal and if ???? is zero we have:
????2 = ????2 + ????2
As can be seen in Appendix C the vector can be drawn as a right-angle triangle and so the vector ???? can be easily found once you know ???? at the point of impact.
See Appendix D for the full formula for collisions between moving balls and this can be used in all cases.
Note: You must comment code liberally to explain your steps.
The Coursework will be marked based on the following marking criteria
Marking Criteria Maximum component mark
Task 1: Vector maths library – to achieve high marks the library must be correct, well coded, and simple to use and be reusable. Marks are per correct function implemented (see main specification). Marks will be lost if the code is not testable so you must produce a test case. 25
Task 2 Part A: Trajectory in 3D for a projectile with restitution (sphere must bounce on landing) and the bounce must realistically correspond to change in the restitution value. This must be correct for high marks and meet all requirements. It must include the ability to change the velocity at design time. Code must be reusable e.g. for a different game object. 10
Task 3 Waypoint scene. Waypoints must be movable at design time and still be followed correctly. Motion must be continuous, and you must be able to the set the speed at design time as shown. Code must be reusable e.g., for a different number of waypoints. For maximum marks the motion around the waypoint must be implemented (there are 7 marks for this part). 15
Task 4: Part A: Vector reflection – for high marks you must take into account the dimensions of the spheres so that the bounces from the boundaries look realistic and all reflections must be correct. Dynamic friction must be applied to slow the balls down to an eventual stop. 25
Task 4 Extension: 2D conservation of momentum problem for an elastic collision at an angle. This must be mathematically correct and look realistic (balls move correctly after impact) for high marks and must meet all requirements. Secondary moving ball collisions need to be handled for maximum marks. 25
Total 100

Marking Grade Descriptors – for guidance only
80-100: An outstanding piece of work: All assessment criteria have been met at an exceptionally high standard
• Displays sophistication and originality in developing the solutions??
• Demonstrates rigour in mathematical technique ?
• Demonstrates complete and fit for purpose reusable solutions
• Demonstrates high detail of realism in all simulations
• Communicates complexity clearly and succinctly with excellent standard of presentation in the viva
70-79: An excellent piece of work: All assessment criteria have been met at a high standard
• Demonstrates sophisticated solutions ?
• Demonstrates rigour in mathematical technique
• Provides a robust and correct solution with some minor issues?
• Provides a high-quality realistic simulation
• Communicates ideas clearly and succinctly with good standard of presentation in the viva
60-69: Good piece of work: Demonstrates sound solutions to the problems
• Solutions presented are mathematically correct and rigorous
• Solution may be somewhat incomplete but presented work is correct
• Solutions presented behave reasonably realistically
• Communicates ideas clearly with a good standard of presentation in the viva
50-59: A sound piece of work: Most assessment criteria have clearly been met.
• Solutions all work but are not easily adaptable or reusable or not optimal solutions
• May lack mathematical rigour.
• Most simulations offer and element of realism but issues such as imprecise collision detection exists ?
• Communicates ideas using an appropriate format with few weaknesses in presentation
40-49: Significant parts of the assessment criteria are not met.
• Provides limitations in the practice and approach
• Demonstrates lack of analysis leading to issues on the simulations
• Some realism achieved in the simulations
• Lacks mathematical rigour
• Communication is unclear with significant weaknesses in presentation during the viva
0-39 FAIL: Most of the relevant assessment criteria area not been met.
• Demonstrates poor understanding of key concepts and techniques
• Shows significant weaknesses and omissions in completing the task
• Insufficient analysis
• Mathematics incorrectly applied
• Communication is unclear with major weaknesses in presentation in viva
Appendix A – class files
This appendix contains starter code for the 3D Vector library. Note that the maths library shall use static class methods only and be called Vector3DMaths. Note Vector3 is a built-in structure so no need to create this.
//3D Vector Maths Library
public static class Vector3DMaths {
//all static class methods as pure utility
//this deals with 3D vector maths
/**
* Vector addition
*/
public static Vector3 addVectors(Vector3 v1, Vector3 v2) {
Vector3 result = new Vector3(); //necessary maths here return result;
}
… the rest of the class
}
Appendix C – Simplified Billiard ball problem –ball B has an initial velocity of zero

Appendix D – Two moving ball collision formula
This is the equation for calculating the final velocity of a two-ball collision where both balls are moving. This also works for the case of one moving ball (e.g. cue ball) and a second stationary ball.
Apart from the masses everything here is a vector quality
X1 and X2 are position vectors of the ball centres at the point of impact.
The angle brackets signifies a dot product of the vectors (v1 – v2) and (X1 – X2) etc.
?? is the final velocity and ?? is the initial velocity.
Note that || X2 – X1|| etc. is the magnitude of the vector subtraction X2-X1
If the masses are equal, then the mass term at the beginning reduces to be equal to 1
Appendix E – Euler method for Equation of motion
Pseudo-code for Euler method for equations of motion
Set up variables and constants: gravity vector, acceleration vector, initial velocity vector, initial position vector, time interval deltaT etc. Use this for all of the problems and note that for the waypoint problem the acceleration a is zero.
Loop – in Unity use the Update() method .
{
?? = ?? + ?? * ???????????? ?? = ???????? + ?? * ????????????
//update the objects position
//check if you need to change the motion e.g. position of projectile is below zero so need to bounce etc.
}
Note – if noted in bold above then these are vectors quantities
End of document

Private and Confidential

Yours all information is private and confidential; it is not shared with any other party. So, no one will know that you have taken help for your Academic paper from us.



This essay is written by:

Prof. Amanda Verified writer

Finished papers: 435

Proficient in:

English, History, Business and Entrepreneurship, Nursing, Psychology, Management

You can get writing help to write an essay on these topics
100% plagiarism-free

Hire This Writer
© 2017 theacademicessays. All Rights Reserved. Design & Developed by theacademicessays.

Ask Your Homework Today!

We have over 1000 academic writers ready and waiting to help you achieve academic success

CLICK HERE TO GET ORIGINAL ANSWERS FROM WRITERS

WhatsApp
Hello! Need help with your assignments?
Loading...