C ++ function for calculating and selecting the projectile trajectory in three-dimensional space. Physical programming

I need to write a function in C ++ that can model and try the trajectory of the trajectory of an object moving through three-dimensional space.

Problem Statement:

The function must accept 3 arguments as input. A function prototype might look something like this:

void CalculateAndSampleTrajectory(Vec3 direction, float impulse, float mass)
{
  //...
}

Vec3 direction is structure. These are essentially 3 floats that behave as a unit vector describing the initial angle of the pulse.

Momentum float is a measure of how powerful the impulse is.

A floating point array describes the mass of the projected object.

3 , , , .

, ( 200) 4 . Vec3s .

SI, - 9.81. .

:

, . , , .

, , , , :

Vec3 velocity = (direction * impulse)/mass;

, , , f = ma, a, . , , , , .

, , , ,

++.

, , 200 4 . :

for(int i = 0; i < 200; i++)
{
    int t = 0;
    //sample equation with t
    //store resulting vec3 pos in array
    t = t + 0.02;
}

t 3 (x, y, z), Vec3.

:

, , , . ++.

, .

+4
1

, ,

enter image description here

t ( t0).

s0, v0, , . .

, , vec3, (9,8 / ^ 2).

, , .

- , .

+2

All Articles