#### Description of this paper

##### Java And Processing Language + Superuniverse

**Description**

solution

**Question**

Question 2 - Superuniverse (or: Don't be afraid of formulas);Your doppleganger from a parallel universe (let's call it the Superniverse) has to write their first assignment as part of their Creative Computation 2 class. In that universe, the basic laws of physics are slightly changed and your doppleganger needs to implement a working simulation (in 2D).;In the Superniverse, objects interact not based on forces, but based on superforces (don't look on Wikipedia for superforces: this is all fictional as you probably have already guessed). The basic formula for a superforce is the following;\vec{S} = \sqrt{m} \cdot \vec{j};where\vec{S} is the superforce, m is the mass and \vec{j} is the jerk.;The jerk is the instant variation of acceleration: in other words, the jerk is to acceleration what acceleration is to velocity (and what velocity is to position).;Objects in our universe move with forces, which are proportional to acceleration. When a force is applied, the object accelerates, acceleration changes velocity, velocity changes the object's position: so the object moves.;Objects in the Superuniverse move with superforces, which are proportional to jerk. When a superforce is applied, it affects the jerk, jerk is applied to acceleration, which in turn is applied to velocity, which changes the object's position: this is how the object moves in the Superuniverse. Notice that like forces are cumulative in our universe, so are superforces: each superforce modifies the jerk in a cumulative way.;2a - Super movers;Start with the Mutual attraction example from The Nature of Code examples. Make sure you understand the code and add comments wherever they are missing.;Rename the class Mover to SuperMover and adapt it to the Superniverse setting by adding a jerk vector and replacing the applyForce(PVector) method with an applySuperForce(PVector) method (you will need to respect the superforce formula). The update() method should also be changed to account for the influence of jerk.;Make sure you respect encapsulation by never accessing directly position, velocity, acceleration and jerk from outside the class. You should only change the position, velocity, acceleration and jerk by calling the applySuperForce(PVector) and the update() methods.;2b - Superdistance;The Superniverse lies in a non-Euclidian space and therefore, the Euclidian distance cannot be used to compute supergravity;d = \sqrt{ (u_x - v_x)^2 + (u_y - v_x)^2 + (u_z - v_z)^2 };Instead, the Superniverse uses the Manhattan distance (also called the 1-norm distance or the Taxicab distance) to compute the superdistance d_s between two objects;d_s = | u_x - v_x | + | u_y - v_y | + | u_z - v_z;Notes;The symbol | a | refers to the absolute value of a (thus the function abs() in Processing).;This is only used to compute the distance between two objects for computing supergravity (see below): the magnitude of a vector remains the same (cf. the PVector.mag() and the PVector.normalize() methods).;Create a method in your sketch that returns the Manhattan distance between two vectors;float superDistance(PVector u, PVector v) {... };2c - Supergravity;The Superniverse has two basic forces that are alway present: supergravity and superfriction. You will need to implement them.;The first superuniversal superforce is called supergravity.;You will recall that the formula in our universe to compute the force of gravity (p. 88) is;\vec{F}_g = G m_1 m_2 / d^2 * \hat{r};In the Superuniverse, the equivalent of the law of gravity is called supergravity and has the following formula;\vec{S}_g = G_s (m_1 + m_2) / d_s * \hat{r};where G_s is the superuniversal gravitational constant, m_1 and m_2 is the mass of the two objects, d_s is the superdistance (see subquestion 2.2) between the two objects and $\hat{r}$ is the unit vector going from object 1 to object 2.;Change the method attract(SuperMover m) for a method superAttract(SuperMover m) that implements the supergravity. The value for G_s can be adjusted at your own choice.;2d - Superfriction;The second superuniversal superforce is called superfriction. Unlike friction (which is related to velocity), superfriction is related to both velocity and acceleration. The formula of superfriction is;\vec{S}_f = - \mu_s \parallel\vec{v}\parallel \parallel\vec{a}\parallel \hat{v};where \mu_s is the superuniversal superfriction constant, \vec{v} is the velocity vector and \vec{a} is the acceleration vector. Remember that \parallel \vec{x} \parallel stands for the magnitude of vector \vec{x} and that \hat{x} is the normalized version of vector \vec{x}.;Add a method in SuperMover that returns the superfriction applicable on the SuperMover instance and use the function to apply friction on all mover instances. The value for \mu_s can be adjusted at your own choice.;This is an example of what the result looks like (quite super-crazy, heh?);Bonus *;Replace the Manhattan distance in your calculations by the Minkovsky distance with a parameter that controls theorder of the distance (see below). The Minkovsky distance is defined as;d(p) = \{ | u_x - v_x |^p + | u_y - v_y |^p + | u_z - v_z |^p \}^{1/p};Where p is the order of the distance. Notice that if p = 1, the Minkovsky distance is equal to the Manhattan distance, whereas if p = 2 it is equal to the Euclidian distance.

Paper#70376 | Written in 18-Jul-2015

Price :*$37*