Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: python  (Read 4825 times)

0 Members and 1 Guest are viewing this topic.

Ädamas

    Topic Starter


    Beginner

    Thanked: 1
    python
    « on: November 08, 2009, 01:10:08 AM »
    this python code is supposed to graph the motion of a projectile but i do not know how to stop it from 'sinking' (it goes below the x axis a bit) and i don't know if it is accurate.i also want it in Si units but i don't think it is doing that right.


    Code: [Select]
    from __future__ import division
    from visual import *
    from visual.graph import *
    print"""
    type stat(p1,p2,p3,v1,v2,v3,a1,a2,a3)
    then type run()
    an example is stat(0,4,0,1,2,0,0,-9,0)"""
    def stat(pos_x,pos_y,pos_z,vel_x,vel_y,vel_z,acc_x,acc_y,acc_z):
        pos = vector(0,0,0)
        pos.x = pos_x
        pos.y = pos_y
        pos.z = pos_z
        velocity = vector(0,0,0)
        velocity.x = vel_x
        velocity.y = vel_y
        velocity.z = vel_z
        acceleration = vector(0,0,0)
        acceleration.x = acc_x
        acceleration.y = acc_y
        acceleration.z = acc_z
        dt=.0001
        t=0

        posgraph=gcurve(color=color.green)
       
        while pos.y>=0:
            pos+=t*velocity+(t*t*acceleration)/2
            posgraph.plot(pos=(pos.x,pos.y))
            t+=dt
            if pos.y<0:
                print "time:" ,t
                print 'Position',pos
                #print 'velocity',velocity
                print " "
    when i run it with this

    stat(0,4,0,1,2,0,0,-9,0)
    it outputs this:

    time: 0.6674
    Position <2226.78, -0.564899, 0>
     
    you're just jealous because the voices talk to me, and not you.

    gh0std0g74



      Apprentice

      Thanked: 37
      Re: python
      « Reply #1 on: November 08, 2009, 01:58:19 AM »
      post it to comp.lang.python

      Ädamas

        Topic Starter


        Beginner

        Thanked: 1
        Re: python
        « Reply #2 on: November 10, 2009, 02:01:07 AM »
        i don't know what that is?
        you're just jealous because the voices talk to me, and not you.

        Salmon Trout

        • Guest
        Re: python
        « Reply #3 on: November 10, 2009, 12:52:23 PM »
        i don't know what that is?

        In that case, you probably won't be experienced with Usenet, so you could try this

        http://groups.google.com/group/comp.lang.python/topics

        Or you could learn how to write Python programs...


        Ädamas

          Topic Starter


          Beginner

          Thanked: 1
          Re: python
          « Reply #4 on: November 12, 2009, 02:24:41 AM »
          can you tell me about usenet
          you're just jealous because the voices talk to me, and not you.

          Salmon Trout

          • Guest
          Re: python
          « Reply #5 on: November 12, 2009, 02:54:36 AM »
          You can read about Usenet on Google or click the link I gave you.