npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

projectile-motion-with-air-resistance

v1.0.3

Published

This package will take a variety of inputs concerning a spherical projectile, and it's initial conditions, and calculate it's trajectory with air resistance proportional to the velocity squared.

Downloads

6

Readme

projectile-motion-with-air-resistance

What does this do?

This function calculates the distance,time of flight, and maximum height for the flight of a projectile, fired over flat ground, experiencing air resistance proportional to its velocity squared.

Instructions for use

npm i projectile-motion-with-air-resistance

projectile(initalVelocity,launchAngleInRadians, dragCoeffiecient, mass, crossSectionalArea, gravitationAlCoefficient, airDensity)

import projectile from 'projectile-motion-with-air-resistance

console.log(

  projectile(
    initalVelocity=10, 
    launchAngleInRadians=0.5, 
    dragCoeffiecient=4, 
    mass=3, 
    crossSectionalArea=2, 
    gravitationAlCoefficient=9.82, 
    airDensity=1 )
    )

// Output: 
//  {
//    maximumHeight: 0.33662516367922946,
//    horizontalRange: 1.3804636233789596,
//    timeOfFlight: 0.5067819524975948
//  }

Parameters

  • initalVelocity: Initial velocity of the projectile in meters per second.
  • launchAngleInRadians: Launch angle of the projectile in radians.
  • dragCoeffiecient: Drag coefficient of the projectile. (spherical projectile)
  • mass: Mass of the projectile in kilograms (kg).
  • crossSectionalArea: Cross-sectional area of the spherical projectile in meters. (pi * radius^2)
  • gravitationAlCoefficient: Acceleration due to gravity in meters per second squared (m/s^2).
    • default: 9.81
  • airDensity: Density of the air (fluid) which the projectile is traveling through in kilograms per meters cubed (kg/m^3)
    • default: 1.29

About this repository

This repository is the source of the projectile-motion-with-air-resistance npm package, It is a function that uses numerical integration and newtons method to calculate the distance, time of flight, and maximum height of a projectile experiencing air resistance proportional to velocity squared. See https://en.wikipedia.org/wiki/Projectile_motion for more information on this interesting problem in physics. This code is heavily based on the example given there.

Why does this matter?

The solution for this problem with air resistance proportional to the velocity of a projectile is solved analytically. In other words, there is a known solution for every situtation. However, air resistance does not usually act that way, and for, say, a baseball, the air resistance is more closely proportional to the velocity squared of the object. This problem is not solved analytically, and needs to be approximated with a variety of common numeric methods.

What does it accomplish

This package accomplishes that solution to the problem described above, in javascript, in case anyone ever wants to do these calculations in a web browser.

What can be improved?

The approximations surroudning numerical integration, and newton's method could be improved. The air resistance proportional to the velocity (not velocity squared) could be factored in. As well as the velocity cubed. The density of air is assumed to be constant with height, as is the acceleration due to gravity, neither of which is true. The curve of the earth is not accounted for. This is only a spherical projectile, other shapes could be accounted for. The drag coefficient could also be accounted for