by ivanjermakov · 11mo ago · 0 comments
applyDrag(): void {
const { quad: quadConfig } = settings
const quad = this.getRigidBody()
const quadVel = vec3ToTwgl(quad.linvel())
const dragMag = aerodynamicDrag(quadConfig.dragCoefficient, v3.length(quadVel), quadConfig.frontalArea)
const dragDir = v3.negate(v3.normalize(quadVel))
const dragForce = v3.mulScalar(dragDir, dragMag)
const dragImpulse = v3.mulScalar(dragForce, dt)
quad.applyImpulse(vec3TwglToRapier(dragImpulse), true)
}
This way code gets more natural language anchors which helps understanding what it does. (fn some-function [args]
(let [binding (transform args)]
(an-expression binding)))
I find that this makes skimming lisp code much easier, because I can usually skip reading the bindings and just read the function name and ultimate expression and usually get the gist very quickly.You might wonder how this is different than the example you provided, and the answer is because you could sneakily intersperse anything you wanted between your imperative bindings (like a conditional return statement), so I actually have to read every line of your code, vs in a lisp `let` I know for a fact there is nothing sneaky going on.
I see this a lot in the wild, though - as an honest question (not trolling!) why do people still shorten their variable names in place of having a terse descriptor ?
aerodynamicDrag(DragInput.builder()
.dragCoefficient(quadConfig.dragCoefficient),
.speed(v3.length(quadVel))
.referenceArea(quadConfig.frontalArea)
.build()
)
which i think points at a possible bug where there drag coefficient isnt measured for the frontal area and needs to be rescaled?