Transform to local axis question

Transform to local axis question

Postby Pixero » Wed Nov 06, 2019 8:57 am

What is the best way of doing a transform along a components local axis?
Is it:
Code: Select all
component.transformation.inverse * new_transform * component.transformation

Or can one apply a new transform, let's say:
Code: Select all
new_transform = Geom::Vector3d.new(1, 0, 0)
to a local axis directly?
1
User avatar
Pixero 
 

Re: Transform to local axis question

Postby fredo6 » Wed Nov 06, 2019 7:42 pm

Pixero wrote:What is the best way of doing a transform along a components local axis?

It all depends on what you wish to transform and where it is.
1
User avatar
fredo6 
PluginStore Author
PluginStore Author
 

Re: Transform to local axis question

Postby Pixero » Thu Nov 07, 2019 8:29 am

I want to transform a component along its internal local axis and settled with:
Code: Select all
c_trans = c.transformation.clone
c.transform!(c_trans.inverse)
c.transform!(Geom::Transformation.translation(@vector))
c.transform!(c_trans)


It works for this case but it has always felt backwards to me and I'm interested if there is a way to do the same with some matrix multiplication magic instead?
0
User avatar
Pixero 
 

Re: Transform to local axis question

Postby fredo6 » Thu Nov 07, 2019 11:34 am

Pixero wrote:I want to transform a component along its internal local axis and settled with:

You mean that you want to translate the component along:
- one of its axis?
- a given vector? (what is @vector in your code snippet?)

In any case, you can compute the transformation, and then apply it once, via c.transformation =.
0
User avatar
fredo6 
PluginStore Author
PluginStore Author
 

Re: Transform to local axis question

Postby Pixero » Thu Nov 07, 2019 11:47 am

The thing is that @vector could be any value but it is in World-space coordinates and I want to move the component from its current position and rotation in its own local axis coordinates the length of @vector. @vector could be either just a x value or in any other combination like (25, 50, 43).

What I do above is inversing the components transformation and then applying the @vector global axis transformation and finally returning the component to its rotation.
Can it be done the other way? transforming the global @vector values into the components local coordinatsystem and applied.
0
User avatar
Pixero 
 

Re: Transform to local axis question

Postby fredo6 » Thu Nov 07, 2019 5:36 pm

If the vector is given in world coordinates, then you need the total transformation from the top model to the component.

This is not something you can derive from the component itself. Usually it comes from
1) a picking process in an interactive tool
2) or the knowledge of the chain of containers from the top model down to the component
1
User avatar
fredo6 
PluginStore Author
PluginStore Author
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 7 guests

Visit our sponsors: