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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Move model Item to 0,0,0

HectorAtLmco
7-Bedrock

Move model Item to 0,0,0

Hello. I have what should be two SIMPLE tasks in JS, but I cannot seem to be able to get Vuforia to do what I need:

1. Move pvz assembly from assembly coordinates to Vuforia's 0,0,0. This should be as simple as getting the geometric center of the model item and subtracting it! For example, if your assembly is at (1.1, 2.2, 3.3) all I should have to do it say modelItem.x -= modelItem.x and voila! Problem solved. No. Apparently knowing the ACTUAL location of a model requires black magic.

 

2. Once a model is finally placed at (0,0,0) I need to be able to rotate it IN PLACE. Alas, changing modelItem.rx/ry/rz results in undesired positions. 

 

I've read through the posts on transformations, but the answer is eluding me. Any help is greatly appreciated!

4 REPLIES 4

Hi @HectorAtLmco ,

I think this is not simple. The movement itself is simple but to find the geometrical center of the model, this is something which is not easy , at least in Studio, so far I know.

First want to point  to following article "Mechanism Concept in Vuforia Studio- How to make rotation more easy". It is related to the question about the rotation of parts about some axis.

The problem is the following (I have experience with Creo  and will  mentioned from this aspect). When we create a part it have a default coordinate system We can create a lot of new Coordinate system  and use them in Creo Parametric, but unfortunately Vuforia View /also in Studio will understand only the first default coordinates system for the point 0,0,0 and e.g. will rotate the part only about this point. The Cad System , in this case Creo will solve the problem applying transformation matrix between CSYS to default CSYS, then between part def CSYS to Subassembly CSYS to ROOT assembly CSYS. In  Studio view it seem that it used only the transformation from default csys part to default CSYS of assembly.

For example for rotation we can use the option in the article mentioned above.- pay attionon when we design the geometry  or calculate and use the transformation matrix.  IN the CAD tool there is no problem to calculate this transformation information . So we possibly could pass it down by parameters which could be read by the meta data. Please see also “Incorporate CAD Metadata Into an Experience

But this was only some general information. TO understand the problem I need an example where we have some sample assembly, part geometry where specific movement and rotation is desired to find what is in this case the root cause.

 

Hi Roland! Thank you so much for replying!

 

Oof. This sounds SUPER involved. I KNOW what I am trying to do is possible through the GUI in Studio, since you can take the XYZ Triad and move and rotate a widget IN PLACE and the x/y/z/rx/ry/rz of the widget gets updated automatically. Would it be possible for you to ask DevOps how THEY do it? It may be something they can share as a class in JS and would benefit the whole community!

 

If you tell me we cannot get any help from them, then I'll bite the bullet and proceed to try to do all the calcs myself.

 

Thanks again!

Hi,

 

I would be very interested in this, too. I have a similar case. I want to move the spatial target to the position of the part that is beeing clicked on. This enables the view user to have the rotation center right at the part that is inspected. Right now I use direction buttons to move it, but this is not optimal. Looks like this, if anybody needs it:

 

var interVal=0.1;
$scope.move=function(direction , widget){
var yRotation=$scope.view.wdg[widget].ry;
saved = false;
console.log("direction:"+direction);
switch (direction){
case 'x':
$scope.view.wdg[widget].x += interVal*Math.cos(yRotation*Math.PI/180);
$scope.view.wdg["center"].x = $scope.view.wdg[widget].x;
$scope.view.wdg[widget].z = $scope.view.wdg[widget].z - interVal*Math.sin(yRotation*Math.PI/180);
$scope.view.wdg["center"].z = $scope.view.wdg[widget].z;
break;

....

Hi @HectorAtLmco ,

I saw that this post was without attention. I am sorry for the delay. Is it possible to discus this on specific model example. Where we can see what the goal is there. 

So far my understanding , you want to be able to specify the rotation via specific Coordinate system. I think we can do this by transformation matrix - and so far I now this is the current approach used by the most cad software.

So possibly we need something like to find :

  • what is the current component CSYS (means the location where we will rotate the component when we set the properties rx,ry,rz(
  • to be able to set this rotation. Example: setCSYSofComponent (componentModelitem, x,y,z,rx,ry,ry) where the x,y,z,rx,ry,rz is the Euler transformation shift and roatation in respect to the current coordinate system of the component - means the coordinate which is used for the rotation axes when we set rx,ry,ry in the UI - of the modelItem Studio UI.
  • When we set to this component the new CSYS then perform some translation and rotation regarding to the new CSYS setXYZ_RXRZRZforComponent(compId,x,y,z,rx,ry,rz)

Is that what you want to do?

Thanks

Top Tags