Home › Forum › SOFA › Using SOFA › [SOLVED] Change point indices when using PartialLinearMovementConstraint
- This topic has 3 replies, 2 voices, and was last updated 2 years, 11 months ago by Hugo.
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
12 December 2021 at 13:49 #21124bayminBlocked
Hi,
I am using ‘PartialLinearMovementConstraint’ to move some points on the object.
But during the simulation, when I change the indices of the points to move, the position the the new point will become (0, 0, 0).Thank you so much for help,
baymin
12 December 2021 at 16:44 #2112613 December 2021 at 14:58 #21137bayminBlockedHi @Hugo,
I found that I can solve this problem by defining multi-motion in the beginning.
self.motion1 = LiverFEM.createObject('PartialLinearMovementConstraint', indices='100', keyTimes='0', template='Vec3d', movements='0 0 0') self.motion2 = LiverFEM.createObject('PartialLinearMovementConstraint', indices='105', keyTimes='0', template='Vec3d', movements='0 0 0')
But if I just define one motion and just change the indices of motion, the second point will move from (0, 0, 0).
We use the liver demo and our animation function is as below
def onBeginAnimationStep(self, deltaTime): ## Please feel free to add an example for a simple usage in /home/trs/sofa/build/unstable//home/trs/sofa/src/sofa/applications/plugins/SofaPython/scn2python.py cT = self.LiverFEM.getTime() position1 = self.LiverFEM.getObject('dofs').position[100] position2 = self.LiverFEM.getObject('dofs').position[105] position = [position1, position2] movements = self.LiverFEM.getObject('PartialLinearMovementConstraint').findData('movements').value keyTimes = self.LiverFEM.getObject('PartialLinearMovementConstraint').findData('keyTimes').value indices = self.LiverFEM.getObject('PartialLinearMovementConstraint').findData('indices').value self.control_point_index = self.control_point_index + 1 if self.control_point_index >= 200: self.control_point_index = 0 ind = self.control_point_index // 100 motion = [[0, 0, 0], [0, 0, 0]] T_dec = cT / deltaTime / 100 * 2 * 3.1415926 motion[ind] = [0.5*math.sin(T_dec), 0.5*math.sin(T_dec), 0] print('ind motion', ind, motion) self.motion1.findData('keyTimes').value = [[cT], [cT + 100]] self.motion1.findData('movements').value = motion[0] self.motion2.findData('keyTimes').value = [[cT], [cT + 100]] self.motion2.findData('movements').value = motion[1]
Best
baymin
10 January 2022 at 16:27 #21341 -
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.