sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Scale non-uniform along vector?

    Scheduled Pinned Locked Moved Developers' Forum
    22 Posts 4 Posters 1.8k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jolranJ Offline
      jolran
      last edited by

      Edit: Think the method works now 😍

      Not 100% tested in all angles yet. Changed my code in previous post.

      1 Reply Last reply Reply Quote 0
      • jolranJ Offline
        jolran
        last edited by

        Oops. Sorry Dan, must have typed while you post your message.

        Your info: Really? Did not have a clue about that. Thats is good news for further developpment. Thank you.

        1 Reply Last reply Reply Quote 0
        • jolranJ Offline
          jolran
          last edited by

          Ah typical 😞 . Too early to celebrate.. It doesent work of axis= face tilted.

          Get strange new error no implicit conversion to float from nil

          I guess group_x=group.transformation.xaxisis only gonna work if the group is aligned to global axis. Therefore when tilted it has nothing=nil??

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            group.transformation.x_axis

            is returning the vector of the component's local x axis. It should never return nil I don't think. I can't play with your code at the moment, but maybe later today I can test it out.

            You should note that its possible/normal? for 2 vectors to perpendicular to the one you're testing against. So it will scale in 2 directions, not just one (I think).

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              gt=group.transformation og=gt.origin xa=gt.xaxis ya=gt.yaxis
              [ za=face.normal
              or za=xa.cross(ya)]
              Use a rotation transformation about og and za by the angle_between xa and vector ?
              Then do a scaling transformation along the xaxis only to match (vector.length / groupX.bounds.width) [where you have used add_instance on group.entities.parent [==definition] temporarily added to the face.parent.entities, at the origin with no further transformation as groupX ?]
              Then invert the rotation transformation...
              All done ?

              TIG

              1 Reply Last reply Reply Quote 0
              • jolranJ Offline
                jolran
                last edited by

                @unknownuser said:

                is returning the vector of the component's local x axis

                So it IS the local axis we are dealing with here. Since the scaling is only working on Global axis I persumed it wasen't. Thats good then(hopefully).

                @unknownuser said:

                You should note that its possible/normal? for 2 vectors to perpendicular to the one you're testing against. So it will scale in 2 directions, not just one

                Uh oh 😲 That's NOT good! I will do some further testing to se if it fails.

                Thanks for all your help.

                1 Reply Last reply Reply Quote 0
                • jolranJ Offline
                  jolran
                  last edited by

                  Hello TIG. I typed when your answer came in. Bad timing today πŸ˜„

                  Will try your code and report back. Looks interesting.

                  Thanks a million!!

                  1 Reply Last reply Reply Quote 0
                  • jolranJ Offline
                    jolran
                    last edited by

                    I'm not sure I quite understand where to use you code, TIG. When Importing the component definition?
                    That could be difficult in this case...
                    This particular tiling is in it's own method. In the plugin there are other "tiling" methods. So cannot do any altering to the component def. before calling the method of choice. Unless I rewrite the definition loader-method. Could be done of course..

                    In your code: vector.length / groupX.bounds.width. Is that to determine the scale?

                    The way this feature will work in the plugin, is that the USER determin number of rows, some code like: edge.length/numbers of rows to determin groupX.bounds.width.

                    So I'll add that part to your code-snippet?

                    Edited. Changed some info to clarify things, it's not good to write topics saturday nights πŸ˜„:
                    I think Chris was right about conflicts i vectors(Edge can be perpendicular to 2 axes of course).
                    So I've scrapped that code..
                    See if I can incorporate TIG's code, and see if it works. I think I get the idea of it.


                    fitrow.jpg

                    1 Reply Last reply Reply Quote 0
                    • jolranJ Offline
                      jolran
                      last edited by

                      @unknownuser said:

                      gt=group.transformation
                      og=gt.origin
                      xa=gt.xaxis
                      ya=gt.yaxis
                      [za=face.normal
                      or za=xa.cross(ya)]
                      Use a rotation transformation about og and za by the angle_between xa and vector ?
                      Then do a scaling transformation along the xaxis only to match (vector.length / groupX.bounds.width) [where you have used add_instance on group.entities.parent [==definition] temporarily added to the face.parent.entities, at the origin with no further transformation as groupX ?]
                      Then invert the rotation transformation...
                      All done ?

                      Is it that this code is to be used when comp.definition( or group) is at Origin=flat on "ground"?
                      Cause I get some funky results.. Havent tried "hard" yet. Will elaborate more after lunch....

                      I've tried something like this where vector is edge:

                      gt=group.transformation
                      			og=gt.origin
                      			xa=gt.xaxis
                      			ya=gt.yaxis
                      			za=@face.normal #@face=reference to the face.selection
                      			za=xa.cross(ya) #??
                      			
                      			x_to_vec=xa.angle_between vector
                      			
                      			tr1=Geom;;Transformation.rotation(og, za, x_to_vec)#req. rotation angle
                      			group.transform!(tr1)
                      			
                      			ts = Geom;;Transformation.scaling(og, scaling, 1, 1)		
                      			group.transform!(ts)
                      			
                      			tr=tr1.invert!
                      			group.transform!(tr)
                      
                      1 Reply Last reply Reply Quote 0
                      • jolranJ Offline
                        jolran
                        last edited by

                        BTW:

                        This special kind of tiling method will not take any rotation(angle) other than 90.degrees as an argument. The group(hatches) will always have to be perpendicular to the edge.

                        1 Reply Last reply Reply Quote 0
                        • TIGT Offline
                          TIG Moderator
                          last edited by

                          the group is from its untransformed bounds [from a temporary instance of it added to the face.parent.entities].

                          You know how long the 'edge' is [edge.length] so you can work out the ratio of the two values...
                          Now you can use that to scale the group.entities with a scaling-transformation along the xaxis only... and thereby the original group is scaled as needed.
                          Erase the temporary instance of the group to tidy up...

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • jolranJ Offline
                            jolran
                            last edited by

                            Yeah, thanks TIG. All what you say is true.

                            All these transformations got my head spinning. So I ditched the scaling in the tilingmethod. Went with scaling(y in this case) at ORIGIN, just after loading the component. Before placing it on the face. Not as flexible as in a method, but it will hopefully work. I think Dan suggested something similar, earlier on in this thread.

                            Maybe that's what you had in mind all along as well, TIG. I just coulden't see it then..

                            Edit: When I reread you thread, did you mean to scale entities and that would become a "local" scale? Cause i did some scaling in x or y and it was in fact a global scale. The group moved from the face and tilted, even when putting the origin at center of bbox. I can't recall 100% sure if it was the group OR the entities I scaled. Ah heck. I'll try tomorrow then.. Like I said, rather had this transformation separate in the tiling method..

                            1 Reply Last reply Reply Quote 0
                            • 1
                            • 2
                            • 1 / 2
                            • First post
                              Last post
                            Buy SketchPlus
                            Buy SUbD
                            Buy WrapR
                            Buy eBook
                            Buy Modelur
                            Buy Vertex Tools
                            Buy SketchCuisine
                            Buy FormFonts

                            Advertisement