• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

[Plugin] Perpendicular Face Tools (UPDATED 26-03-09)

Scheduled Pinned Locked Moved Plugins
201 Posts 64 Posters 174.4k Views
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.
  • L Offline
    linea
    last edited by 12 Mar 2009, 08:06

    Thanks Chris.

    1 Reply Last reply Reply Quote 0
    • E Offline
      erikB
      last edited by 12 Mar 2009, 09:15

      Chris,
      Thanks for the usefull ruby !
      erikB

      1 Reply Last reply Reply Quote 0
      • C Offline
        Chris Fullmer
        last edited by 13 Mar 2009, 03:00

        Your response hasn't gone un-noticed Tig. I thank you immensely for it. I'm still working on implementing it 😳 I think there is a small flaw in that I don't point C either. I think I know how to get it, so thats good. In fact, it is essentially what you provided with the "cosine rule". Thanks for that! That is currently what I'm working at. I had one method, but it was rather convoluted and started to fall apart for some reason, so I think it must not have been sound. This new method feels much more mathematically correct. I'll let you know how it goes. Hopefully within a few hours. Thanks sooo much for your help and ideas,

        Chris

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

        1 Reply Last reply Reply Quote 0
        • T Online
          TIG Moderator
          last edited by 13 Mar 2009, 09:23

          To rotate the square you have more than enough info. You don't actually need point-D.

          You want to rotate it about the centre-point [let's call it point-O] - so you know that too.
          You know point-A and point-C as you have them initially or have just calculated them already.
          Now find the angle between the two vectors O->A and O->C.***
          Select all of the square's edges (face will go with them?) and make a rotation-transformation about point-O by that angle: using the normal to the square's face as the axis of rotation...

          Points A and C, and points B and D will then be coincident...


          "new vector"
          v = [x,y,z]
          vector1 = Geom::Vector3d.new(v)

          Where v [x,y,z] is obtained from the sum of the two points v = (pointO - pointA) etc

          you might also want to ".normalize" the vector(s)...

          Find vector2 (O->C) the same way...

          "angle_between vectors"

          The angle_between method is used to compute the angle (in radians) between this vector and another vector.

          Syntax

          angle = vector1.angle_between(vector2)

          Arguments

          vector2 - a Vector3d object

          Return Value

          angle - an angle (in radians)

          Example

          vector1 = Geom::Vector3d.new(x,y,z)
          vector2 = Geom::Vector3d.new(xx,yy,zz)

          angle = vector1.angle_between(vector2)

          ###########

          A bit more complicated to my mind is doing it with the 'cosine rule',

          here it is though - you can easily find the length 'AC'

          you have the other two points and can use 'AC = pointA.distance(pointC)' method for that.

          You also know the circle's Radius - or can easily get it from the square's side dim.

          Angle = Math::acos((RadiusRadius + RadiusRadius - ACAC) / (2Radius))

          Note: if Angle > 90 degrees (pi/2) then it's negative...

          .

          TIG

          1 Reply Last reply Reply Quote 0
          • M Offline
            MALAISE
            last edited by 14 Mar 2009, 15:03

            Hi Chris

            Small feedback : using customer shape crashes SU ( under Windows XP 3)without any message.

            MALAISE

            La Connaissance n'a de valeur que partagée

            1 Reply Last reply Reply Quote 0
            • C Offline
              Chris Fullmer
              last edited by 14 Mar 2009, 22:36

              @malaise said:

              Hi Chris

              Small feedback : using customer shape crashes SU ( under Windows XP 3)without any message.

              MALAISE

              Oh dear, thats not good. Can anyone else confirm? I don't have xp sp3 anywhere to test it on. Is it possible that it is a conflict with another script? That doesn't seem likely to me since I think I've written my code so that can not happen.

              I do have xp sp2 I can test it on. Perhaps if I can duplicate it there, I can narrow down the problem. Thanks for the notice,

              Chris

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

              1 Reply Last reply Reply Quote 0
              • D Offline
                Dave R
                last edited by 14 Mar 2009, 22:41

                Chris, I've done a couple of experiments with it. No crashes yet. I've got XP Pro SP3.

                Dave

                Etaoin Shrdlu

                %

                (THERE'S NO PLACE LIKE)

                G28 X0.0 Y0.0 Z0.0

                M30

                %

                1 Reply Last reply Reply Quote 0
                • E Offline
                  Ecuadorian
                  last edited by 15 Mar 2009, 07:35

                  An artist who is also a coder?
                  That's Chris Fullmer!

                  Thank you very much for taking the time to code this; with a couple of tweaks, this will be perfect. 😎

                  -Miguel Lescano
                  Subscribe to my house plans YouTube channel! (30K+ subs)

                  1 Reply Last reply Reply Quote 0
                  • M Offline
                    MALAISE
                    last edited by 15 Mar 2009, 07:52

                    OK, let me see which plugin may be in conflict 👍

                    MALAISE

                    La Connaissance n'a de valeur que partagée

                    1 Reply Last reply Reply Quote 0
                    • M Offline
                      MALAISE
                      last edited by 15 Mar 2009, 07:54

                      Hi ALL

                      Filtering the last downloaded plugins, I've found a conflict with Jim's cd_power_n.rb ( mover2.rb) Has someone experienced that? several times tested.

                      ( SU V7, Windows XP SP3 )

                      MALAISE ❓

                      La Connaissance n'a de valeur que partagée

                      1 Reply Last reply Reply Quote 0
                      • C Offline
                        Chris Fullmer
                        last edited by 15 Mar 2009, 08:24

                        Very Interesting. I have that plugin installed with no conflicts. I'll dig around tomorrow and see what I can find. Sorry for the inconvenience,

                        Chris

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

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          MALAISE
                          last edited by 15 Mar 2009, 09:13

                          Thanks for playing attention, no matter for inconvenience, don't worry 😄
                          MALAISE

                          La Connaissance n'a de valeur que partagée

                          1 Reply Last reply Reply Quote 0
                          • J Offline
                            Jim
                            last edited by 15 Mar 2009, 13:18

                            @malaise said:

                            Hi ALL

                            Filtering the last downloaded plugins, I've found a conflict with Jim's cd_power_n.rb ( mover2.rb) Has someone experienced that? several times tested.

                            ( SU V7, Windows XP SP3 )

                            MALAISE ❓

                            Mover2 does not use a file or method named cd_power_n.rb.

                            Hi

                            1 Reply Last reply Reply Quote 0
                            • C Offline
                              Chris Fullmer
                              last edited by 15 Mar 2009, 15:55

                              I know, its cad_fathers's SCF powertools toolbar plugin that wrapped mover2 into a file called cd_power_n.rb. If you open that file, its just your script. So I'm guessing it has something to do with how its being loaded from his main plugin loader maybe? I don't know. I know I've got my whole script wrapped in a class so I thought I should not have conflicts. But perhaps there is more to it than that.

                              Chris

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

                              1 Reply Last reply Reply Quote 0
                              • T Online
                                TIG Moderator
                                last edited by 16 Mar 2009, 09:37

                                I'm not getting bug-splats with custom-face, BUT it does inconveniently make a group of the selected face and not explode it at the end. It's easily fixed by adding a line of code after line #299, to explode the temporary group...

                                @group.explode
                                

                                How's the orienting face rotation on end of line going ?
                                .

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • M Offline
                                  MALAISE
                                  last edited by 16 Mar 2009, 13:51

                                  I've tried this improvement, the group is still present, not exploded. ❓

                                  MALAISE

                                  La Connaissance n'a de valeur que partagée

                                  1 Reply Last reply Reply Quote 0
                                  • C Offline
                                    Chris Fullmer
                                    last edited by 16 Mar 2009, 15:54

                                    Hey Tig, I probably could explode the group without any conflicts. I was thinking I didn't want the added face to interefere with the model, but its probably not an issue. Or maybe I explode it by default and have a ctrl key modifier that leaves it grouped. I've been wanting to figure out modifier keys.

                                    As for the rotation thing, I still have not got it worked out 😞 I'm having a hard time pinpointing point C from my diagram above. I got close and it sort of worked, but it fell apart if the face was too slanted or something and I got so frustrated I have not even looked to figure out why. I'm sure its a million times easier than I'm making it. Since I can't find "C" yet, I intersected a flat plane with the face plane to get an intersection vector. That vector is the vector that I want my top(or bottom) edge to exist on. So I then did an angle_between the 2 vectors (the found one and the existing edge one) to get the angle that I want to rotate the face. That seemed to work in testing, but did not work well once I put it in the script. Sorry to drag this out. I'll probably put some more time into it today since I got a few other scripts updated last night.

                                    @Malaise, I think maybe that added the ungroup function to the custom face tool only, and maybe you tested it on one of the other tools. It would need to be added for each tool. I'll look into it, and maybe even get it implemented sometime this century 😄

                                    Thanks everyone, thanks TIG!

                                    Chris

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

                                    1 Reply Last reply Reply Quote 0
                                    • T Online
                                      TIG Moderator
                                      last edited by 17 Mar 2009, 09:26

                                      It's the original face that needs to be un-grouped. I agree that the face put on the end of the line is best left grouped to allow you to move its origin or rotate it about the line etc - you can explode it before doing a followme etc...

                                      Here's my thinking on the rotation conundrum...

                                      Let's do the square for now - seems to me that first you make a group containing a 'flat' square with its centre set at the origin and then move it to the select vertex at the end of the edge, transform rotating it so its face is perpendicular to the picked-vertex's edge... So far so good. Now we check the geometry of the square - it only has four vertices, so find the two with the lowest Z-value***. These are the vertices of the bottom-most edge. Now find the mid-point between them - we use this to work out the vector from the 'centre' (picked-vertex's location) to this mid-point and the angle between that and a 'vertical' vector in the same plane as the face: that 'angle' is the angle that we'll use later on to rotate everything so that it is 'orthogonal' to the XYZ axes.

                                      Let's call the centre 'c' and two lowest points 'p1' and 'p2' - these are known - and the mid-point we'll call 'm' - that we need to get...
                                      To find a point mid-way between two others use...

                                       m = Geom;;Point3d.linear_combination(0.5,p1,0.5,p2) 
                                      

                                      We can then get the vector from 'c' to 'm', let's call it 'cm' - simply subtract the point values...

                                       cm = c - m 
                                      

                                      Now to find the 'vertical vector' (let's call it 'vv') - first find a point ('t') 1 unit away from 'c' above the surface of the face by the edge's [positive] 'vector' and then project it down till it hits the face at 'v' - the line between 'c' and 'v' is the 'vertical vector' against which we'll rotate the face...

                                       t = c.offset(vector,1)
                                       ang = (t-c).angle_between(t-[0,0,-1]) # i.e. the tilt on face normal
                                       hyp = 1/Math;;cos(ang) # i.e. the drop from t to face plane
                                       h = [t.x,t.y,(t.z)-hyp] # i.e. the point t projected onto the face's plane
                                       vv = c-h # the vertical vector
                                      
                                      

                                      Now get it's angle to the 'mid-point vector'

                                       angle = vv.angle_between(cm) 
                                      

                                      You then need to work on the face of the square and transform/rotate the whole thing around the picked-vertex's edge by the 'angle'... Done.

                                      ***Note: IF the Z of all of the square's vertices is the same [simple test to look at the four] then it's 'flat' so then we'll find the lowest two Ys and rotate it to be orthogonal about the Z axis instead. Also note that in this 'flat' case the 'vertical' vector needs to be (0,-1,0) to match the Y...

                                      For the custom face do something similar but group the face, copy it, explode the original back to where it was and then use the copy's bounding box centre as its 'origin', move and transform it to the vertex, use the new location's bounds to get an enclosing rectangle to get minimum Zs etc, all as above etc etc...

                                      I haven't tried this code, but it should at least form the basis of something that''ll work...

                                      .

                                      TIG

                                      1 Reply Last reply Reply Quote 0
                                      • C Offline
                                        Chris Fullmer
                                        last edited by 17 Mar 2009, 18:44

                                        Thanks for walking me through this TIG. Hopefully I'll get a chance to try to get this implemented tonight or tomorrow. Lots of work-work and school-work today 😞

                                        Chris

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

                                        1 Reply Last reply Reply Quote 0
                                        • C Offline
                                          cosycat
                                          last edited by 17 Mar 2009, 21:19

                                          looking at this, I wondered how difficult it would be to create a script that 'blended' between two diffrent faces at either end of a line.

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 3
                                          • 4
                                          • 5
                                          • 10
                                          • 11
                                          • 2 / 11
                                          2 / 11
                                          • First post
                                            31/201
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement