Commits

German Larrain committed 9779f67

In SimulatedObject, rotate method was implemented. New getters and setters for rotation and position

  • Participants
  • Parent commits a221c19
  • Branches default

Comments (0)

Files changed (1)

File ars/model/simulator/__init__.py

 		self._geom = geom
 	
 	def rotate(self, axis, angle):
-		raise NotImplementedError()
+		'''
+		Rotate the object by applying a rotation matrix defined by the given axis and angle.
+		'''
+		rot_now = mu.matrix_as_3x3_tuples(self.get_rotation())
+		rot_to_apply = mu.matrix_as_3x3_tuples(mu.calc_rotation_matrix(axis, angle))
+		# the rotation matrix to be applied multiplies from the LEFT the actual one
+		rot_final = mu.matrix_as_tuple(mu.matrix3_multiply(rot_to_apply, rot_now))
+		self.set_rotation(rot_final)
 	
 	def offset_by_object(self, object_):
 		offset_pos = object_.get_body().getPosition()
 # GETTERS AND SETTERS
 #===============================================================================
 	
+	def set_position(self, position):
+		self._body.setPosition(position)
+			
+	def set_rotation(self, rot_matrix):
+		self._body.setRotation(rot_matrix)
+	
 	def get_name(self):
 		return self._name
 	
 	
 	def get_position(self):
 		return self._body.getPosition()
+		
+	def get_rotation(self):
+		return self._body.getRotation()
 	
 class SimulatedJoint: