score:2
Accepted answer
i had to remove all of the angular/typescript stuff, but you should be able to run the below code and paste the output into a graphing program and verify it. what i'm doing is calculating the angle required to travel the distance input, then calculating the x and y vectors of the initial velocity. then you can just multiply those by a timestep to get points that you can plot. if you want more granular points, just increase the step variable.
const calctrajectory = (distance, height, velocity)=> {
// get target distance - passed in
// get launch angle to hit target at that distance
let x = distance;
let y = height;
let g = 10.733; // gravity in yds
let v = velocity / 3; // velocity in yds
let angle = math.asin((x*g)/(v*v));
let step = 100;
let xvelocity = v * math.cos(angle);
let yvelocity = v * math.sin(angle)
// graph x y coords based on target distance, launch angle, and bullet drop
let data = {x:[], y:[]}
for (let i = 0; i < 100; i++) {
let time = (i / step);
data.x.push(time*xvelocity)
data.y.push(time* yvelocity)
yvelocity -= (g/step)
}
console.log(data);
}
calctrajectory(250, 0, 2024.43)
Source: stackoverflow.com
Related Query
- Calculate x and y coords for bullet trajectory - Chart.js
- How to add second Y-axis for Bar and Line chart in Chart.js?
- Problem for display a chart with Chart.js and Angular
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- How to create a chart that uses strings for both the X and Y axes?
- How to draw outer labels for polar chart using ng2-charts and chart.js at fixed positions outside the rings?
- How do I customize y-axis labels and randomly pick the value from the data range for x-axis in Chart js
- How can I have different values for the chart and the tooltip in chart.js?
- Click on interactive chart.js bar chart and get value for labels and groups in JS
- How do you set x and y axis and Title for a line chart using charts.js?
- Charts JS: Doughnut chart and hiding tooltip for specific data index within each dataset
- attempting to change height and width of canvas for chart
- getting additional value fields from data source for dx.chartjs doughnut chart
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- Frontend and backend for chart using chartjs, mongodb, and controller
- Line chart plotting multiple points for duplicate data on x and y axis using chart.js
- Chart.JS Get Json data for chart and return dataset where a type equals a certain type
- Chart js pie chart, darker shade for higher value and lighter shade for lower value. I'm displaying values monthly
- Initializing Chart Js Multiple times for and Array of Objects
- No chart display for Chart.js and JSON data
- how to create bar chart with group and sam color for each group using chart.js?
- Chart JS Custom tooltips with % and label for X and Y axles
- How to set max and min value for Y axis
- In Chart.js set chart title, name of x axis and y axis?
- Comparison between d3.js and chart.js (only for charts)
- How can labels/legends be added for all chart types in chart.js (chartjs.org)?
- Chart Js Change Label orientation on x-Axis for Line Charts
- Chart.js - Increase spacing between legend and chart
- Chartjs random colors for each part of pie chart with data dynamically from database
- Chartjs v2 - format tooltip for multiple data sets (bar and line)
More Query from same tag
- (Ionic 3) How to make font size of labels in charts.js responsive?
- Problem displaying two graphs on a single chart using javascript and chart.js
- ChartJS Draw grid line X-Axis and Y-Axis
- multiple line charts with independent data Javascript (Chart.js or google-vizualisation)
- chartjs tooltip is cut off when out of canvas
- How to create single value Doughnut or Pie chart using Chart.js?
- Populate chart.js from data table / SQL result set
- Stack grouped xAxes in bar chart
- ChartJS: Limit Y Axis to cut outlimit values
- Chart.js padding not working for ScaleLabel
- Sort a Chart from Lowest to Highest Value in Chart JS
- The scale on the axis doesn't automatically narrow
- how to dynamically render and update chart.js line graph
- how to set title in legend of chart.js?
- How to push element in array in a certain structure
- ChartJs: How to pan programmatically by time values (instead of pixels)
- Change the font size of chart.js with chartkick
- Multiple labels for multiple data-sets in chart.js
- Chart.js - y axis custom label
- Same bar different color / One bar with many colors
- I would like to show a line bar in chart.js with data automatically fetched from mockapi
- How to use generated HTML legends to enable or disable datasets in Chart.js
- Chart JS - single lines (points) tooltips
- How to skip labels on x-axes?
- Angular 6 Charting Google Sheets API Data
- how to add tool tip in yii-chartjs extension
- Parse 2d int array to List of BubbleDataPoints
- Chart.js canvas is empty / white in node.js
- How to set a time scale to a ChartJS chart from JSON?
- Can't get event from chartjs-annotation-plugin on mouseenter