CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sun, 10 Aug 2025 18:31:10 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20080415022647
location: https://web.archive.org/web/20080415022647/https://www.daniweb.com/code/snippet842.html
server-timing: captures_list;dur=0.497190, exclusion.robots;dur=0.017876, exclusion.robots.policy;dur=0.008574, esindex;dur=0.009187, cdx.remote;dur=306.711532, LoadShardBlock;dur=339.952502, PetaboxLoader3.datanode;dur=183.820063
x-app-server: wwwb-app218
x-ts: 302
x-tr: 672
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app218; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sun, 10 Aug 2025 18:31:11 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Tue, 15 Apr 2008 02:26:47 GMT
x-archive-orig-server: Apache/2.2
x-archive-orig-x-powered-by: PHP/5.1.6
x-archive-orig-set-cookie: bblastactivity=0; expires=Wed, 15-Apr-2009 02:26:47 GMT; path=/; domain=.daniweb.com
x-archive-orig-cache-control: private
x-archive-orig-pragma: private
x-archive-orig-vary: Accept-Encoding,User-Agent
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Tue, 15 Apr 2008 02:26:47 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Tue, 15 Apr 2008 02:26:47 GMT", ; rel="memento"; datetime="Tue, 15 Apr 2008 02:26:47 GMT", ; rel="next memento"; datetime="Wed, 09 Jul 2008 07:30:20 GMT", ; rel="last memento"; datetime="Sun, 08 Feb 2009 21:15:45 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 51_3_20080414223743_crawl103-c/51_3_20080415022548_crawl104.arc.gz
server-timing: captures_list;dur=0.498790, exclusion.robots;dur=0.014314, exclusion.robots.policy;dur=0.006899, esindex;dur=0.009498, cdx.remote;dur=647.727890, LoadShardBlock;dur=174.320921, PetaboxLoader3.datanode;dur=145.335060, PetaboxLoader3.resolve;dur=365.197023, load_resource;dur=381.633533
x-app-server: wwwb-app218
x-ts: 200
x-tr: 1290
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
Graphing Projectile Motion with wxPython - python
Graphing Projectile Motion with wxPython
•
•
•
•

What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 311,439 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,787 IT professionals currently interacting right now! If you are in the IT industry or are just a technology enthusiast, you might find just what you're looking for in DaniWeb. Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Modernize Legacy Data with Sybase
This well commented Python snippet uses wxPython's plotting widget to graph the projectile motion of two different firing angles on the same plotting canvas.
# using wxPython for plotting projectile motion # draw line graph for 2 different firing angles # tested with Python25 and wxPython28 vegaseat 26mar2008 import wx import wx.lib.plot as plot import math class MyFrame(wx.Frame): def __init__(self): self.frame1 = wx.Frame(None, title="wx.lib.plot", id=-1, size=(410, 340)) self.panel1 = wx.Panel(self.frame1) self.panel1.SetBackgroundColour("yellow") # set up the plot canvas plotter = plot.PlotCanvas(self.panel1) plotter.SetInitialSize(size=(400, 300)) # enable the zoom feature (drag a box around area of interest) plotter.SetEnableZoom(True) # projectile motion equations: # height = y(t) = h0 + (t * v * sin(a)) - (g * t*t)/2 # range = x(t) = v * cos(a) * t # where: # v is the muzzle velocity of the projectile (meter/second) v = 100 # a is the firing angle with repsect to ground (radians) # h0 is starting height with respect to ground (meters) h0 = 0 # g is the gravitational pull (meters/second_square) g = 9.8 # now calculate the list of (x, y) data point tuples ... # x axis is range (distance) in meters # y axis is height in meters # first for a firing angle of 45 degrees d = 45 a = math.radians(d) # gives radians data45 = [] for t in range(0, 200): # use the time in increments of tx (0.1) seconds tx = t/10.0 # now calculate the height y y = h0 + (tx * v * math.sin(a)) - (g * tx * tx)/2 # calculate the range x x = v * math.cos(a) * tx # append the (x, y) tple to the list data45.append((x, y)) # now for a firing angle of 30 degrees d = 30 a = math.radians(d) # gives radians data30 = [] for t in range(0, 200): # use the time in increments of tx (0.1) seconds tx = t/10.0 # now calculate the height y y = h0 + (tx * v * math.sin(a)) - (g * tx * tx)/2 # calculate the range x x = v * math.cos(a) * tx # append the (x, y) tuple to the data list data30.append((x, y)) # draw points as a line # 2 different lines one for an angle of 45 one of 30 degrees line45 = plot.PolyLine(data45, colour='red', width=1) line30 = plot.PolyLine(data30, colour='blue', width=1) # set up the plot gc = plot.PlotGraphics([line45, line30], 'Projetile Motion', 'range (meters) firing angle red=45, blue=30', 'height (meters)') # and draw it plotter.Draw(gc, xAxis=(0,1200), yAxis=(0,300)) self.frame1.Show(True) app = wx.PySimpleApp() f = MyFrame() app.MainLoop()
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)