sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Vector comparison - positive or negative maybe?

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 2 Posters 237 Views 2 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.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      Hi, I have a dilema where I need to rotate an face either by a positive or negative degree depending on the face normal (slightly simplified from what's really going on, but only slightly).

      I'm hoping that perhaps there is some mathematical term or function that will help me set this up. Here's the scenario.

      The table below hopefully shows what I need. The X,Y,Z columns are the direction of the vector. So for example, the "+ + +" one would be a vector that is headed in the positive X, positive Y, and positive Z direction.

      X Y Z

          • = Positive rotation
          • = Positive rotation
          • = Positive rotation
          • = Positive rotation
          • = Negative rotation
          • = Negative rotation
          • = Negative rotation
          • = Negative rotation

      Is there some sort of math function that describes these vectors? If not, I am planning on doing a huge comparison of OR and AND over the vector.x vector.y and vector.z values to categorize the vector into one that should result in a positive rotation or a negative rotation.

      I'd prefer to avoid the monster comparison if possible. I am hoping that these vectors are like called positive vectors and negative vectors or something.

      does that make any sense?

      Thanks,

      Chris

      I'll probably be building my comparison if statements in the meantime πŸ˜„

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

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

        As I worked this out in my head, I see the comparson is really only going to be
        (not syntactically correct πŸ˜„ )
        if (z > 0 and x>0) or (z < 0 and x > 0)
        rotate positive
        else
        rotate negative
        end

        I'd still be interested if there is a math term that describes the vectors or something like that. Thanks,

        Chris

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

        1 Reply Last reply Reply Quote 0
        • fredo6F Offline
          fredo6
          last edited by

          Chris,

          As a hint, the mathematical way is to used vectorial product (in your case, vec X * vec Y). The result is a vector vec Z, which you test whether it is in the same direction or not as the face normal (via the scalar product %).

          Fredo

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

            Are the first two vectors (x and y) the vectors that define the angle of rotation? So I should multiply those two vectors together and they will either equal or be the opposite of my face normal....is that sort of right?

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

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

              Hey!, that is what you meant. And it is in fact returning a parallel vector. I'll write it into my code and see if .samedirection? is enough to help me decide whether to rotate with a negative or positive value. Thanks!

              Chris

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

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

              Advertisement