5 messages in com.googlegroups.sketchuprubyRe: more transformation questions| From | Sent On | Attachments |
|---|---|---|
| bve...@gmail.com | 23 Jan 2008 01:32 | |
| JimF | 23 Jan 2008 02:42 | |
| bve...@gmail.com | 23 Jan 2008 15:29 | |
| JimF | 23 Jan 2008 18:26 | |
| bve...@gmail.com | 23 Jan 2008 18:33 |
| Subject: | Re: more transformation questions![]() |
|---|---|
| From: | bve...@gmail.com (bve...@gmail.com) |
| Date: | 01/23/2008 03:29:56 PM |
| List: | com.googlegroups.sketchupruby |
i have to disagree with you. in the first part of my post i said try the following
tt1 = Geom::Transformation.new([10,20,30]) tt2 = Geom::Transformation.new([40,50,60]) tt1.set!tt2 tt1 tt2
while it is true that set! returns a transformation object equal to tt2 it also sets tt1 equal to tt2
full transcript: tt1=Geom::Transformation.new([10,20,30])
[1.0, 0.0, 0.0, 0.0] [0.0, 1.0, 0.0, 0.0] [0.0, 0.0, 1.0, 0.0] [10.0,20.0, 30.0, 1.0]
tt2=Geom::Transformation.new([40,50,60])
[1.0, 0.0, 0.0, 0.0] [0.0, 1.0, 0.0, 0.0] [0.0, 0.0, 1.0, 0.0] [40.0,50.0, 60.0, 1.0]
tt1.set!tt2
[1.0, 0.0, 0.0, 0.0] [0.0, 1.0, 0.0, 0.0] [0.0, 0.0, 1.0, 0.0] [40.0,50.0, 60.0, 1.0]
tt1
[1.0, 0.0, 0.0, 0.0] [0.0, 1.0, 0.0, 0.0] [0.0, 0.0, 1.0, 0.0] [40.0,50.0, 60.0, 1.0]
tt2
[1.0, 0.0, 0.0, 0.0] [0.0, 1.0, 0.0, 0.0] [0.0, 0.0, 1.0, 0.0] [40.0,50.0, 60.0, 1.0]
as you can see, without ever using transform! or transformation= i have made tt1 and tt2 equal.
On Jan 23, 5:42 am, JimF wrote:
I think you've created an "anonymous" transformation.
ss.transformation.set!Geom::Transformation.new([10,20,30])
returns a transformation, it does not apply the transformation to anything. You still need to apply the transformation to the object you want to transform. Breaking it down:
ss.transformation # returns a Transformation object (anonymous)
(anonymous).set! Geom::Transformation.new([10,20,30]) # set! is applied to the anonymous transformation.
the transformation of ss is never changed. You want:
ss.transformation = Geom::Transformation.new([10,20,30]) or ss.transform! = Geom::Transformation.new([10,20,30])
depending.
On Jan 23, 4:32 am, "[email address]" wrote:
is it just me or does this function do absolutely nothing?
based on the documentation it sounds like it should change transformation1 INTO transformation2.
go ahead and type the following into the ruby console
tt1 = Geom::Transformation.new([10,20,30]) tt2 = Geom::Transformation.new([40,50,60]) tt1.set!tt2 tt1 tt2
both of them are equal sounds pretty self explainitory, right? i wish...
throw a component into your model and select it then try this ss=Sketchup.active_model.selection.first ss.transformation ss.transformation.set!Geom::Transformation.new([10,20,30]) ss.transformation
there seems to be a problem here.
all i want to be able to do is edit the scale of the component, from inside the Transformation class. i think there is some functionality missing from the class and i want to put it in. ive got a start on accessors. but that wont do much good if you can modify the transform afterward.
just so we are clear i know there are easier ways to do what im trying to do but i think it should be part of the transformation class and i want to beable to add it in.
here is what i have so far
class Geom::Transformation
def to_s
print "\n"
myArray = self.to_a
"[#{myArray[0]}, #{myArray[1]}, #{myArray[2]},
#{myArray[3]}]\n"+
"[#{myArray[4]}, #{myArray[5]}, #{myArray[6]},
#{myArray[7]}]\n"+
"[#{myArray[8]}, #{myArray[9]}, #{myArray[10]},
#{myArray[11]}]\n"+
"[#{myArray[12]},#{myArray[13]}, #{myArray[14]},
#{myArray[15]}]\n"
end
def getTranslationTransform Geom::Transformation.new(self.origin) end
# these will get the ABS of the scale. # a negitive scale will be indicated by a 180 degree rotation in the relevent places def xscale self.to_a[0]/self.xaxis.x end def yscale self.to_a[4]/self.yaxis.x end def zscale self.to_a[8]/self.zaxis.x end
def xscale=(scale) tt=Geom::Transformation.scaling scale,self.yscale,self.xscale self.set! self*tt end #def yscale= # #end #def zscale= # #end end




