This commit is contained in:
Benjamín 2021-09-07 07:19:23 +02:00
parent e112ce52e3
commit be4d8e0ff9
3 changed files with 4 additions and 7 deletions

@ -22,12 +22,13 @@ class RopeInteractiveDot:
if clicked: if clicked:
for object_batch in self.scene.get_i_objects(): for object_batch in self.scene.get_i_objects():
rmp = object_batch[1] # relative mouse position
for object_ in object_batch[0]: for object_ in object_batch[0]:
if object_.__class__.__name__ == "Rope": if object_.__class__.__name__ == "Rope":
for node in object_.nodes: for node in object_.nodes:
if node.locked is False: if node.locked is False:
if math.sqrt(sum((node.position - self.position) ** 2)) < self.forcefield_range: if math.sqrt(sum((node.position - rmp) ** 2)) < self.forcefield_range:
force_vector = node.position - self.position force_vector = node.position - rmp
full_force_vector = (force_vector / math.sqrt(sum(force_vector ** 2))) \ full_force_vector = (force_vector / math.sqrt(sum(force_vector ** 2))) \
* self.forcefield_range * self.forcefield_range
force_vector = full_force_vector - force_vector force_vector = full_force_vector - force_vector

@ -2,7 +2,6 @@ from numpy import array as a
from UI.Objects.Multiscene import Multiscene from UI.Objects.Multiscene import Multiscene
from UI.Objects.nr_objects.Line import Line from UI.Objects.nr_objects.Line import Line
from UI.Objects.nr_objects.controllable_objects.RopeInteractiveDot import RopeInteractiveDot
from UI.Scenes.RopeScene import RopeScene from UI.Scenes.RopeScene import RopeScene
@ -20,9 +19,6 @@ class RopeMultiscene(Multiscene):
l0 = Line(a([200, 0]), a([200, 400]), 10, (255, 100, 100), self) l0 = Line(a([200, 0]), a([200, 400]), 10, (255, 100, 100), self)
rd0 = RopeInteractiveDot(a([0, 0]), 10, (100, 255, 100), 20, 100, self)
#self.nrc_objects.append(rd0)
self.sort_objects(s0, s1, l0) self.sort_objects(s0, s1, l0)
self.i = 0 self.i = 0

@ -11,7 +11,7 @@ import time
screen_size = a([200, 500]) screen_size = a([200, 500])
scene = RopeMultiscene(screen_size) scene = RopeScene(screen_size)
mouse_pos = [0, 0] mouse_pos = [0, 0]
clicked = False clicked = False