Open ian-c-hamilton opened 3 years ago
https://github.com/p5py/p5/blob/master/p5/pmath/vector.py#L327
Use mouse.magnitude
instead of mouse.magnitude()
as magnitude
is defined as a property
of the class Vector
.
( If you know C++ / Java think of magnitude
as a variable name instead of a function of the class Vector
. )
couldn't we also have .mag()
?
Perhaps adding something like:
def mag(self):
return self.magnitude
Just for more compatibility with the Processing PVector class? https://py.processing.org/reference/PVector_mag.html
Describe the bug Docs have vector magnitude function as "Vector.mag()". Currently implemented as "Vector.magnitude". When adding the additional "()" like all other vector functions, an error is given. See below.
To Reproduce Run code:
Expected behavior Should calculate magnitude.
Error Traceback WARNING: Traceback (most recent call last): File "d:/Google Drive/Personal/Programming/The Nature of Code/1 - Vectors/Mouse Following Vector.py", line 34, in
run()
File "c:\Users\Ian\anaconda3\lib\site-packages\p5\sketch\userspace.py", line 166, in run
app.run()
File "c:\Users\Ian\anaconda3\lib\site-packages\vispy\app_default_app.py", line 62, in run
return default_app.run()
File "c:\Users\Ian\anaconda3\lib\site-packages\vispy\app\application.py", line 152, in run
return self._backend._vispy_run()
File "c:\Users\Ian\anaconda3\lib\site-packages\vispy\app\backends_glfw.py", line 194, in _vispy_run
self._vispy_process_events()
File "c:\Users\Ian\anaconda3\lib\site-packages\vispy\app\backends_glfw.py", line 183, in _vispy_process_events
timer._tick()
File "c:\Users\Ian\anaconda3\lib\site-packages\vispy\app\backends_glfw.py", line 516, in _tick
self._vispy_timer._timeout()
File "c:\Users\Ian\anaconda3\lib\site-packages\vispy\app\timer.py", line 168, in _timeout
count=self.iter_count)
File "c:\Users\Ian\anaconda3\lib\site-packages\vispy\util\event.py", line 455, in call
self._invoke_callback(cb, event)
File "c:\Users\Ian\anaconda3\lib\site-packages\vispy\util\event.py", line 475, in _invoke_callback
self, cb_event=(cb, event))
<< caught exception here: >>
File "c:\Users\Ian\anaconda3\lib\site-packages\vispy\util\event.py", line 471, in _invoke_callback
cb(event)
File "c:\Users\Ian\anaconda3\lib\site-packages\p5\sketch\base.py", line 110, in on_timer
self.draw_method()
File "d:/Google Drive/Personal/Programming/The Nature of Code/1 - Vectors/Mouse Following Vector.py", line 24, in draw
m = mouse.magnitude()
TypeError: 'numpy.float32' object is not callable
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x2316032b888>> for Event
System information:
Additional context Add any other context about the problem here.