Using direct transforms

55 views
Skip to first unread message

Sandino

unread,
Jul 9, 2011, 5:51:46 AM7/9/11
to Sketch Users
Hi,

I'm trying to use a self-defined transformation. Its definition is
straightforward following the manual:

def myTransform [[a,b,c,d][e,f,g,h][i,j,k,l][m,n,o,p]]

But, so far, I have not been able to transform anything. I just don't
know how to use myTransform.


Cheers,
Sandino


Adam Shaver

unread,
Jul 9, 2011, 1:44:06 PM7/9/11
to sketch...@googlegroups.com
I've personally found the best method to define a transform (scale,
rotate, shift, etc) was to define the individual transforms then to
use "then" to string them together.

def myTransform {translate([0,0,-1]) then scale([0.05,0.05,0.3]) then
rotate(-20,30,44)}

Is that what you're asking, or are you trying to create a method that
takes variables a-p and generates a transform function acordingly?

> --
> You received this message because you are subscribed to the Google Groups "Sketch Users" group.
> To post to this group, send email to sketch...@googlegroups.com.
> To unsubscribe from this group, send email to sketch-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sketch-users?hl=en.
>

Sandino

unread,
Jul 10, 2011, 6:17:25 AM7/10/11
to Sketch Users
Hi Adam,

Thanks for your answer. Actually, I wanedt to project a 3D object onto
a plane that could be anywhere.
The projection function (project), as far as I know, projects things
onto a plane parallel to
the plane XY.

So I defined my own projection matrix. My problem was on how to use
that new transformation.
I kept trying and finally found it out!

I just wrote (maybe someone else has the same question)

def projectedPoint [[myTransform]]*(point)

and I got what I wanted.

I don't think I would need to define a transformation from a set of
variables. That would be too much,
I only need one projection matrix. But, I would like to know if is it
possible to transform a whole object,
say, a line or polygon in one go?

Cheers,
Sandino

Sandino

unread,
Jul 10, 2011, 6:51:40 AM7/10/11
to Sketch Users
In fact, what I wrote about the projection can be done with the
projection function and some rotations+translations.
I want to project the same object onto two different planes, each
projection with a different centre of projection...mmm....maybe this
can
also be done without defining a new transformation.

Anyway, I will use my transformation.

Cheers,
Sandino

Gene

unread,
Jul 10, 2011, 9:27:44 PM7/10/11
to Sketch Users
Glad you had success.

The 'put' command will apply any transformation to whatever drawables
are instantiated inside its block.
> > > > For more options, visit this group athttp://groups.google.com/group/sketch-users?hl=en.- Hide quoted text -
>
> - Show quoted text -

Adam Shaver

unread,
Jul 11, 2011, 12:13:32 PM7/11/11
to sketch...@googlegroups.com
Absolutely, it's possible to transform an entire object. Look at the house projection in the manual. First define your object (as a collection of points, lines, sweeps, anything). Then pass the object to the transform.

<Tube.sk>

def tube {
     def tubeConstant1 5
     def tubeConstant2 10
     def aTube  put{translate([0,0,5])} put{rotate(90, [1,0,0])}  {
   def n 10
   sweep{n<>, rotate(360/n,[0,1,0])}
       line[fillcolor=lightgray,fill opacity=0.8,cull=false, linewidth=.1pt](tubeConstant1 ,-tubeConstant2 /2)(tubeConstant1 ,tubeConstant2 /2) }

    % plot aTube
    {aTube}
}

def W2T  rotate(55, [.4,-3,.2])
def T2G rotate(-43, [1,0,0]) then  rotate(15, [0,1,0])
def rotatedTube put{[[T2G]]} {put {[[W2T]]} {tube}}

% Plot with perspective
def eye (-5,10,4)
def look_at (0,0,0)
put { view((eye), (look_at)) }{{rotatedTube}}

</Tube.sk>

Good luck.

Sandino

unread,
Jul 12, 2011, 5:14:53 AM7/12/11
to sketch...@googlegroups.com
Thanks for your answer guys!!! That last example is just great

Cheers,
Sandino
Reply all
Reply to author
Forward
0 new messages