cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Rotate model with button click along Z rotation Axis

awilber
4-Participant

Rotate model with button click along Z rotation Axis

Hello,

I am trying to rotate a model I have across the Z rotational Axis.

 

 

I was using the following code to move the model around the movement axis, but am not sure what i have to change to move it along the rotational axis.

 

Please help!

 

$scope.Rotate = function() {
$scope.view.wdg['755OM'].z = 0.35;
}

 

ACCEPTED SOLUTION

Accepted Solutions

Hi @awilber ,

 

rotaion property should be rx,ry and rz for rotation about the axis X,Y and Z 

The property x,y, and z are movements allong the axis X,Y and Z

Example:

 

  if($scope.view.wdg['toggle-3']['value']==true)
    {
      var angle1=$scope.app.params['door_angle'];  
      var angle1_rad=angle1*Math.PI/180.0;
      $scope.view.wdg['modelItem-door-asm']['rx'] = angle1 ;
      $scope.view.wdg['modelItem-door-asm']['y']  = 0.0 - l_door*Math.sin(angle1_rad);
      $scope.view.wdg['modelItem-door-asm']['z']  = 0.0 - l_door*(1.0-Math.cos(angle1_rad));
    }

 

Here is an example where I rotate an modelItem widget about the x axis and move the rotation point about distance l in Z direction

The usage is the same for model widgets

View solution in original post

5 REPLIES 5

Hi @awilber ,

 

rotaion property should be rx,ry and rz for rotation about the axis X,Y and Z 

The property x,y, and z are movements allong the axis X,Y and Z

Example:

 

  if($scope.view.wdg['toggle-3']['value']==true)
    {
      var angle1=$scope.app.params['door_angle'];  
      var angle1_rad=angle1*Math.PI/180.0;
      $scope.view.wdg['modelItem-door-asm']['rx'] = angle1 ;
      $scope.view.wdg['modelItem-door-asm']['y']  = 0.0 - l_door*Math.sin(angle1_rad);
      $scope.view.wdg['modelItem-door-asm']['z']  = 0.0 - l_door*(1.0-Math.cos(angle1_rad));
    }

 

Here is an example where I rotate an modelItem widget about the x axis and move the rotation point about distance l in Z direction

The usage is the same for model widgets

So would this work?

 

I tried plugging this in and it doesn't seem to work.

 

 

$scope.Rotate = function() {
$scope.view.wdg['755OM'].rz = 0.35;
}

 

 

This should work if you apply it on the correct widget : modelItem or model Widget

The angle is in deg. Means 0-360 for a complette rotation.

0.35 degree is some think which is near to 0 in degree.

Radians are required for the math function like sinus cosinus etc.

Nice!  I missed the part of based on 360 degree scale, worked perfectly!  Thank you for the help!

Here a picture how it should work (the sample code i mentioned)

2019-10-24_14-35-52.jpg

Announcements

Top Tags