/* * 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 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; }