Rotating Target
This example provides information on rotating target around different axis by an angle using Set
Use this procedure to rotate target using SetRelativeTransfrom method.
Create Vector3 object (say rotationVector) based on RotateAxis and angleInDegree parameter values.
Create Matrix4 object which has x=y=z=0 translation value and rotationVector.
Note
This object value will be used to rotate the target without transforming it.
Set target transformation to newRotationMatrix relative to its own local matrix.
Solution
Create Vector3 object (say rotationVector) based on RotateAxis and angleInDegree parameter values.
Vector3 rotationVector = new Vector3(); switch (Convert.ToInt32(value)) { case 0: rotationVector = new Vector3(agnleInRad ,0 ,0); break; case 1: rotationVector = new Vector3(0 ,agnleInRad ,0); break; case 2: rotationVector = new Vector3(0 ,0 ,agnleInRad); break; }
Create Matrix4 object which has x=y=z=0 translation value and rotationVector.
Matrix4 newRotationMatrix = new Matrix4(new Vector3() ,rotationVector);
Set target transformation to newRotationMatrix relative to its own local matrix.
target.Transform.SetRelativeTransform(target.Transform.Matrix ,newRotationMatrix);
Example
This example provides information on rotating target around different axis by an angle.
private static void RotateTargetUsingSetRelativeTransform(RsTarget target ,
RotateAxis value ,double angleInDegree)
{
double agnleInRad = ABB.Robotics.Math.Globals.DegToRad(angleInDegree);
//Create Vector3 object (say rotationVector) based on
//RotateAxis and angleInDegree parameter values.
Vector3 rotationVector = new Vector3();
switch (Convert.ToInt32(value))
{
case 0:
rotationVector = new Vector3(agnleInRad ,0 ,0);
break;
case 1:
rotationVector = new Vector3(0 ,agnleInRad ,0);
break;
case 2:
rotationVector = new Vector3(0 ,0 ,agnleInRad);
break;
}
//Create Matrix4 object which has x=y=z=0 translation value and rotationVector.
Matrix4 newRotationMatrix = new Matrix4(new Vector3() ,rotationVector);
//Set target transformation to newRotationMatrix relative to its own local matrix.
target.Transform.SetRelativeTransform(target.Transform.Matrix ,newRotationMatrix);
}
Required Namespaces
ABB.