Help!

22 views
Skip to first unread message

Amanda Valenti

unread,
Oct 25, 2022, 12:59:57 PM10/25/22
to glowscri...@googlegroups.com
several students are getting this error and I can't find any mistakes.  They have defined everything, no mispellings. 

TYPEERROR:  Cannot read properties of undefined (reading "*")

CODE:  object1.pos.x=object1.velocity.x * deltat + object1.pos.x

I have tried and checke everything and it seems to not like the *.  Looking for help! Thank you. 

Joe Heafner

unread,
Oct 25, 2022, 1:39:08 PM10/25/22
to Web VPython Users
Greetings.

I don't see any obvious errors, and that line works in an example I just coded up and tried. Can you please provide a link to the entire program or copy and paste into a reply?

Joe Heafner
Sent from one of my Macs


Harlan Gilbert

unread,
Oct 25, 2022, 2:12:29 PM10/25/22
to glowscri...@googlegroups.com
Are you sure that object1.velocity is defined as a vector?

--

---
You received this message because you are subscribed to the Google Groups "Glowscript Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glowscript-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glowscript-users/B236C0A7-44C8-4E34-857D-F694063E935C%40gmail.com.


--
Harlan Gilbert, Ph.D.
High School Chair and Math, Physics, Computer Science, and Philosophy Teacher
Green Meadow Waldorf High School
Chestnut Ridge, NY 10977

Joe Heafner

unread,
Oct 25, 2022, 3:06:13 PM10/25/22
to Web VPython Users

> On Oct 25, 2022, at 14:12, Harlan Gilbert <hgil...@gmws.org> wrote:
>
> Are you sure that object1.velocity is defined as a vector?

It was in my example on my end, but when it's defined as a scalar, as in the example below, I do indeed get the same error message. I think that's the problem.

Web VPython 3.2

object1 = sphere(pos=vector(1,2,3),velocity=5)
deltat = 0.01

object1.pos.x = object1.velocity.x * deltat + object1.pos.x

print(object1.pos.x)

Bruce Sherwood

unread,
Oct 25, 2022, 3:20:06 PM10/25/22
to Glowscript Users
Good detective work! I'm surprised to see a statement updating only the x component of a moving object rather than using vectors: object.pos = object.velocity * deltat + object.pos

Bruce
Reply all
Reply to author
Forward
0 new messages