Advertisement

Scale.si units for physics etc.

Started by August 04, 2020 02:29 PM
0 comments, last by _WeirdCat_ 4 years, 6 months ago

Now i encountered some strange feeling ill have to modify kilograms to my own unit.

Basically i choose what scale i use in meaning that lets say 6400 units claim to be 1 meter.

Now what about moving an object at speed 0.1 m/s towards vec3(1.0, 0.0, 0.0) including air resistance and gravity.

This is the first thing i am not really sure

(In order to move an object at speed x (m/s) ill have to apply a force that is desired_speed times its mass)

So lets begin: consider object is a sphere of radius R with mass of 70.0 kg

vec3 forwardforce = vec3(1.0,0.0,0.0) * desired_ max_speed * mass;
vec3 gravity_force = vec3(0.0, -1.0, 0.0)*(9.81 * mass)
vec3 air_form_drag = -normalize(object_vel) * (cl  (air_density * 0.5 * squarelength(vel))*(2.0*pi*sphere_radius);

Then

vec3 result_force = forward_force + gravity_force + air_form_drag;
vec3 accel = result_force / mass;
vec3 new_v = object_vel + accel*dt;
vec3 new_pos = object_pos + new_v*dt;

Aomething like that, without mentioning adding result force vel and pos as a global object variables so simulation goes along.

But how this doea apply to scaled world where one meter is 6400 units?

Speed is known to be meters / second

Accel is meters / squared second

Air density is kiligrams / cubic meters

Mass looks like has to be left unchanged.. same for time (seconds)

Now knowing that 9.81 is earth accel and m/s^2 - it looks like ill just have to multiply 9.81 by 6400

Then i come into air form drag, having drag coefficient set to 1.5 (dont mind for now) i have two quantities one is air density and second is sphere_radius, having sphere radius multiplied by 6400 i get scaled sphere radius but what about air dens when i have 1.225 kg/m^3,

It seems that cubic? root of 1.225 is something near 1.0699874805650795

Imagine i now multiple this by what 6400.0? - this is the part i dont get it

Anyway after calculating forces i end up with velocity vector and position scaled to mach world scale (1 meter = 6400 units)

However im not sure about mass, any thoughts would be appriceated

Scaling only force by 6400.0 doesnt seem to be right

For now i have this code and i gain super light speed..

//instead of moving at speed 0.01 m/s (1 cm / s) it goes 2 meters per second (10000 units / s)
void ProcessFrame(float dt)
{

damp(&FPP_CAM->vel, 100.0f, 0.0070f);
damp(&FPP_CAM->force, 100.0f, 0.0070f);

float mass = 70.0;//kg
ProcessFPPCAMFrame(dt);
float scaled_speed = MetricToScale(FPP_CAM->speed, float(map->one_meter_stands_for_units));

vec3 move_force = mvec * (scaled_speed * mass);

float camv = VectorLength(FPP_CAM->vel);
vec3 vn = -normalize(FPP_CAM->vel);
float scaled_radius = MetricToScale(0.01, float(map->one_meter_stands_for_units));
float scaled_surf = scaled_radius * scaled_radius;
vec3 form_drag = (-vn) * (1.5 * (AIR_DENSITY_SEA_LEVEL * 6400.0 * 0.5 * camv * camv) * (2.0*pi*(scaled_surf))); //form drag


vec3 result_force = move_force + form_drag;
FPP_CAM->force = FPP_CAM->force + result_force;
vec3 accel = result_force / mass;

FPP_CAM->vel = FPP_CAM->vel + accel*dt;

col_handler.HandleCollision((PFComponent*)FPP_CAM, dt);

This topic is closed to new replies.

Advertisement