Seite 1 von 1

Error: Property 'pos' must be a vector. null

Verfasst: Dienstag 20. März 2018, 20:04
von Caturix99
Hey, Ich schreibe ein Programm in VPython. Für den Code habe ich mich an einem Video von Youtube orientiert. Doch als meine Version nicht funktioniert hat, habe ich den Originalcode probiert doch immer noch der selber Fehler:"Error: Property 'pos' must be a vector. null
Hier ist der Code. Über Hilfe bin ich sehr dankbar.

Code: Alles auswählen

GlowScript 2.7 VPython

from visual import *

display(width = 1300, height = 1000)

projectile = sphere(pos = (-5,0,0),
                    radius = 0.1,
                    color = color.red,
                    make_trail = True)

projectile.speed = 3.2 # Initial speed.
projectile.angle = 75*3.141459/180 # Initial angle, from the +x-axis.

projectile.velocity = vector(projectile.speed*cos(projectile.angle),
                             projectile.speed*sin(projectile.angle),
                             0)

projectile.mass = 1.0
grav_field = 1.0

dt = 0.01
time = 0

while (projectile.pos.y >=0):
    rate(100)

    # Calculate the force.
    grav_force = vector(0,-projectile.mass*grav_field,0)

    force = grav_force
    
    # Update velocity.
    projectile.velocity = projectile.velocity + force/projectile.mass * dt

    # Update position.
    projectile.pos = projectile.pos + projectile.velocity * dt

    # Update time.
    time = time + dt

Re: Error: Property 'pos' must be a vector. null

Verfasst: Mittwoch 21. März 2018, 07:42
von noisefloor
Hallo,

poste mal bitte die komplette Fehlermeldung - im Moment ist nicht ersichtlich, in welcher Zeile der Fehler auftritt. Vermutlich Zeile 7, aber das ist nur geraten....

Gruß, noisefloor