12345678910111213141516171819202122232425 |
- /*
- * 2D Physic Engine
- * force.cpp:
- * Based on pikuma.com Learn Game Physics Engine Programming course.
- * Copyright (c) 2022 986-Studio. All rights reserved.
- *
- * Created by Manoël Trapier on 17/06/2022.
- */
- #include <physics/force.h>
- vec2 force::generateDragForce(const particle &particleRef, double k)
- {
- vec2 dragForce;
- if (particleRef.velocity.magnitudeSquared() > 0)
- {
- vec2 dragDirection = particleRef.velocity.unitVector() * -1;
- double dragMagnitude = k * particleRef.velocity.magnitudeSquared();
- dragForce = dragDirection * dragMagnitude;
- }
- return dragForce;
- }
|