Also my 2D Polyline Edit Tool effectively lets you relocate a Polyline's Vertices by picking on them and their new location, one at a time... See its code for how it does those transformations, with a 'ghost polyline' till you end it...
Tossed everything, went "mushin", empty mind, back to the api, and found in one line, exactly what I was trying to do:
new_transformation = Geom::Transformation.new(point,vector_z)
Sigh.....what was I thinking before?-(, Thanks for trying to help.
The right-hand rule: imagine holding the face's normal vector [axis' if you will] in your right-hand, with you thumb pointing in the + direction. Your fingers will curl counter-clockwise.
That rule applies to a face's outer_loop's vertices array.
It also applies to rotations etc about an axis etc...
It's opposite for any inner_loops vertices array - i.e. clockwise.
It doesn't matter which direction/order the face's edges were originally drawn: an array of the loop's vertices is always returned ordered in that particular way - ccw or cw.
The vertices' order does affect the face's normal when drawing faces: however, SUp does seem to have that overriding rule to draw a face with its normal pointing down IF the face's Z=0 !!!
Martin is/was making it far too complex... it even converted the group to a pointless component ?
KISS...
Jim's example is the better way to do it... Explode the group at the end if desired...
Again, I have to recommend Firebug Lite. It has a full featured Javascript console plus HTML DOM and CSS browsers. It works on IE, Safari, Firefox and Chrome and you can add it to any HTML doc with only one (long) line:
<a href="javascript:var firebug=document.createElement('script');firebug.setAttribute('src','http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js');document.body.appendChild(firebug);(function(){if(window.firebug.version){firebug.init();}else{setTimeout(arguments.callee);}})();void(firebug);">Firebug Lite</a>
http://getfirebug.com/lite.html
Thanks Fredo.
I've taken an interests into Bèzier patches. And while I could easily produce a patch using the @Last bezier.rb, I wanted to try to understand more about how it worked technically.
That way I could eventually improve the method I use to create the patch, as at the moment I'm not sure if it's efficient the way I do it.
But yea, Bèzier curves are really cool. Thanks for your feedback Fredo.
Sorry, was a response to this post ......
Jim
Global Moderator
Posts: 2091
Joined: Mon Nov 12, 2007 10:13 pm
Name: Jim Foltz
Operating system: XP Pro SP3
SketchUp version: Google Pro 7.1
.....but the thoughts are free - also my
finewood
@thomthom said:
@tig said:
Thomthom Grumpy...
I came across grumpy?
The English phrase is you were 'terse' [avvisende]... or 'a little short' [litt kort]... just like your old school teacher might be when you ask a seemingly stupid question or you are doing something that is obviously not right [to him] AND he has a hangover etc etc
...
tr=Geom::Transformation.new(group.transformation.origin)
instance=group.entities.add_instance(definition,tr)
or work out where the insertion_point is relative to the group's origin
something like...
insertion_point=[x,y,z]
insertion_point.transform!(group.transformation.inverse)###???
tr=Geom::Transformation.new(group.insertion_point)
instance=group.entities.add_instance(definition,tr)
A group's origin is at ORIGIN [0,0,0] even when it's miles away so you need to move any insert backwards ?
This is untried but my first thoughts...
@chris fullmer said:
I don't quite understand what that means. What is bitwise?
Think in binary, then compare them column for column. It's a logical, bit-to-bit comparison.
5 in binary is 101
6 in binary is 110
5 & 6 is; logical AND each column (bit position)
Columns
________________
| 1 | 0 | 1 <- decimal 5
| and | and | and
| 1 | 1 | 0 <- decimal 6
=================
1 0 0
so 101 & 110 = 100 <- decimal 4
The masks are constants, which are set to some convenient values:
# I just made these up
001 = CONSTRAIN_MASK
010 = ALT_MASK
100 = COPY_MASK
So if the flag is decimal value 7:
111 <- decimal 7
In order to check the CONSTRAIN_MASK, you logical AND the CONSTRAIN_MASK with the flag value:
111 <- flag value decimal 7
& 001 <- contain mask constant
======
001 <- CONSTRAIN_MASK set true
or in real ruby as Thomas wrote;
contrain_key_down = ((flags & CONSTRAIN_MODIFIER_MASK) == CONSTRAIN_MODIFIER_MASK)
copy_key_down = ((flags & COPY_MODIFIER_MASK) == COPY_MODIFIER_MASK)
alt_key_down = ((flags & ALT_MODIFIER_MASK) == ALT_MODIFIER_MASK)
Although Adam B might know a clever way to decode them all in one elegant statement.
well in the end, I've had to mix and match some thoughts from this thread. I realized that I can ont doa simple rotation or scaling because in my case, I have to scale using the components local axis. If their axis is set on one of the sides of the component, I want it to rotate or scae around that axis, not the boundingbox centerpoint.
So I just threw in a way to determine the the center of the component on the local z axis. Had to account for component z-scaling AND if the axis was set somewhere inside the component (not at the very bottom for example). All in all, I've got it working like a charm now (I think!). It will be in the next component stringer.
Chris