Transformations

Transformations

Postby Jim » Tue Oct 06, 2009 8:40 pm

Is it correct that each of these forms creates the same Transformation?

Code: Select all
tr = Geom::Transformation.new(Geom::Point3d.new(1, 0, 0))
p tr.to_a
tr = Geom::Transformation.new(Geom::Vector3d.new(1, 0, 0))
p tr.to_a
tr = Geom::Transformation.translation(Geom::Point3d.new(1, 0, 0))
p tr.to_a
tr = Geom::Transformation.translation(Geom::Vector3d.new(1, 0, 0))
p tr.to_a

0
Hi

Jim 
Global Moderator
 

Re: Transformations

Postby TIG » Tue Oct 06, 2009 10:10 pm

I would expect so...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: Transformations

Postby Chris_at_Twilight » Wed Oct 07, 2009 12:35 am

According to the documentation, yes, they should all be identical. Though the 3rd form isn't in the docs...(I'm looking at the old ones, not the latest).
0

Chris_at_Twilight 
Twilight Render
 

Re: Transformations

Postby Jim » Wed Oct 07, 2009 3:03 am

Well thanks guys - I wanted to start at the beginning.
0
Hi

Jim 
Global Moderator
 

Re: Transformations

Postby MartinRinehart » Wed Oct 07, 2009 6:31 pm

If one of you who has figured on transformations could write a little article for those of us who haven't, it would be a GOOD THING!
0
Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

MartinRinehart 
 

Re: Transformations

Postby TIG » Wed Oct 07, 2009 9:14 pm

This is the basic transformation stuff... ;)
TransformationMatrix.pdf
1
TIG
User avatar
TIG 
Global Moderator
 

Re: Transformations

Postby MartinRinehart » Thu Oct 08, 2009 5:19 pm

TIG wrote:This is the basic transformation stuff... ;)
TransformationMatrix.pdf


That confirms my worst fears.
0
Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

MartinRinehart 
 

Re: Transformations

Postby TIG » Thu Oct 08, 2009 8:22 pm

There are several good methods for getting and changing transformations - relatively easy when you've done it a few thousand times... However, some simple ones are missing - for example if would be nice to be able to get just the angle of rotation out of an existing transformation and then reuse use it in Geom::Transformation.rotation(point,vector, angle)... As it is you can 'clone' the transformation of one thing and apply it to another but that could scale or move it too...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: Transformations

Postby MSP_Greg » Thu Oct 08, 2009 10:51 pm

TIG,

TIG wrote:if would be nice to be able to get just the angle of rotation out of an existing transformation


I think the below might help. I haven't tested it *that* much, and never with 'stretched' trans...

suATan just returns the arctan of the two numbers (x,y), x=0 => +/- 90

Code: Select all
aT = e.transformation.to_a
  # aT[12], aT[13], aT[14]           x, y, z offsets from component origin
  # suATan(aT[0], aT[1])             xy plane angle
  # xy = (aT[8]**2 + aT[9]**2)**0.5
  # suATan(xy, aT[10]) - 90          rise angle, check this one


HTH,

Greg
0

MSP_Greg 
 

Re: Transformations

Postby Jim » Fri Oct 09, 2009 12:46 am

One of the reasons I asked was that I wrote this LDraw importer. But the LDraw axes system does not match SketchUps, and I really want the importer to correct this on import. You can see the import works, but I haven't been able to figure out how to trasnform the geometry during the import so it uses a SketchUp axes that people are familiar with using.
0
Last edited by Jim on Wed Jan 05, 2011 7:00 pm, edited 1 time in total.
Hi

Jim 
Global Moderator
 

Re: Transformations

Postby chrisglasier » Fri Oct 09, 2009 1:35 am

Can I add this topic and particularly this post, to make this topic more complete, even if duplicated in parts.

Thanks

Chris
0
With JSON machines we can analyse what is to be achieved so that IT can help with automation to achieve it.
User avatar
chrisglasier 
PluginStore Author
PluginStore Author
 

Re: Transformations

Postby MSP_Greg » Fri Oct 09, 2009 1:41 am

Jim,

Can you post the file that you used for import shown?

Thanks,

greg
0

MSP_Greg 
 

Re: Transformations

Postby Jim » Sat Oct 10, 2009 6:43 pm

Here it is.
0
Hi

Jim 
Global Moderator
 

Re: Transformations

Postby CPhillips » Sat Oct 10, 2009 7:56 pm

Jim, what is the problem with the brick? The axis look ok to me. Is it that the brick isn't upright?
0

CPhillips 
PluginStore Author
PluginStore Author
 

Re: Transformations

Postby Jim » Sat Oct 10, 2009 8:17 pm

CPhillips wrote:Jim, what is the problem with the brick? The axis look ok to me. Is it that the brick isn't upright?


Yes that is all. One option would be to flip the SKetchUp axes to match the LDraw axes before inporting. But I just want the bricks to be imported using the SU axes instead of the LDraw axes - including the sub-components.

I thought it would simply be a matter of performing an axes transformation on import - but so far the solution has been evasive.
0
Hi

Jim 
Global Moderator
 

Re: Transformations

Postby CPhillips » Sun Oct 11, 2009 2:40 am

Looks like LDraw uses Y is up instead of Z. You could just swap the Y and Z elements when you build the points for the faces. And also swap Y and Z in the translate part of the transform. That will change the axis.
0

CPhillips 
PluginStore Author
PluginStore Author
 

Re: Transformations

Postby CPhillips » Mon Oct 12, 2009 1:45 am

I tried out what I suggested and it totally didnt work. I think it is because of the way scaling is being used. Flip Y and Z and you also need to flip ScaleY and ScaleZ. That is surely possible, but I dont know how to do it.
0

CPhillips 
PluginStore Author
PluginStore Author
 

Re: Transformations

Postby avariant » Mon Oct 12, 2009 3:32 am

Have you tried the Transformation.axes method? It sounds like you should be able to "remap" the standard axes using this transform. Something like Transformation.axes(ORIGIN, X_AXES, Z_AXES, Y_AXES). Just a thought, I have no idea if it will work.
0

avariant 
PluginStore Author
PluginStore Author
 

Re: Transformations

Postby Jim » Mon Oct 12, 2009 3:36 am

That is what I tried to use, but got some crazy results. My initial reaction is to assume I am not understanding how to use them. But if Chris had a problem, I might be inclined to think it's not just me.
0
Hi

Jim 
Global Moderator
 

Re: Transformations

Postby jessejames » Mon Oct 12, 2009 7:19 am

MartinRinehart wrote:If one of you who has figured on transformations could write a little article for those of us who haven't, it would be a GOOD THING!


What do you mean exactly Martin?

1. How do Transformations work on a mathematical level and all the boring details that go along with it?
2. How do i use the Geom::Transformtion class to trans, rotate, and scale stuff in SU?

A huge part of understanding Transformations in a mathematical sense is getting past the cryptic syntax. The good thing about a Transformation class is that you don't need to know crap about advanced math and even some basic college math principals to use the Transformation class quite easily.

Thats one thing i love about programming, code up a class that abstracts away all the details and forget about it! I'll leave the asinine number crunching to my processor!
0
Always sleep with a loaded gun under your pillow!

jessejames 
 

Re: Transformations

Postby MartinRinehart » Mon Oct 12, 2009 2:41 pm

jessejames wrote:What do you mean exactly Martin?

1. How do Transformations work on a mathematical level and all the boring details that go along with it?
2. How do i use the Geom::Transformtion class to trans, rotate, and scale stuff in SU?


# 2

I love those very smart people who can do #1, so the rest of us don't have to.
0
Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

MartinRinehart 
 

Re: Transformations

Postby cjthompson » Mon Oct 12, 2009 3:34 pm

The transformation.axes method just transforms the object so that it's axes match the internal ones.

try using transformation.axes on the grouponent (I believe you used that one ;))

then use
Code: Select all
grouponent.entities.transform_entities(grouponent.transformation.inverse,grouponent.entities.to_a)



EDIT: Just tried it and it should work.
0

cjthompson 
 

Re: Transformations

Postby cjthompson » Mon Oct 12, 2009 4:08 pm

I just looked at the picture you posted again. Do you want flip the axes, instead of rotating them? If so, I don't know if that is possible. It's has to do with the fact that sketchup uses a right hand orientation, instead of left-hand orientation that I'm guessing LDraw uses (http://en.wikipedia.org/wiki/Right-hand_rule).

Is there a way to change the orientation of axes in LDraw? (I haven't used it myself, so I have no idea)
0

cjthompson 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Developers' Forum

Who is online

Users browsing this forum: josecepero1 and 6 guests

Visit our sponsors: