Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Rotation [modified]

Rotation [modified]

Scheduled Pinned Locked Moved The Weird and The Wonderful
6 Posts 4 Posters 25 Views 1 Watching
  • 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.
  • CPalliniC Offline
    CPalliniC Offline
    CPallini
    wrote on last edited by
    #1

    The following was mine :-O Rotation about the point (x,y):

    ...
    double cosa = cos( alfa );
    double sina = sin( alfa );
    for (i=0; i < POINTS; i++)
    {
    x[i] = x + (x[i] - x) * cosa - (y[i] - y) * sina;
    y[i] = y + (x[i] - x) * sina + (y[i] - y) * cosa;
    }

    No surprise if geometrical laws were broken, (:-O again) :) [modified: there was a mistake on code formatting] -- modified at 6:25 Thursday 22nd November, 2007 -- modified at 12:30 Thursday 22nd November, 2007

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

    In testa che avete, signor di Ceprano?

    J 1 Reply Last reply
    0
    • CPalliniC CPallini

      The following was mine :-O Rotation about the point (x,y):

      ...
      double cosa = cos( alfa );
      double sina = sin( alfa );
      for (i=0; i < POINTS; i++)
      {
      x[i] = x + (x[i] - x) * cosa - (y[i] - y) * sina;
      y[i] = y + (x[i] - x) * sina + (y[i] - y) * cosa;
      }

      No surprise if geometrical laws were broken, (:-O again) :) [modified: there was a mistake on code formatting] -- modified at 6:25 Thursday 22nd November, 2007 -- modified at 12:30 Thursday 22nd November, 2007

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      J Offline
      J Offline
      jhwurmbach
      wrote on last edited by
      #2

      CPallini wrote:

      The following was mine

      Sorry, I am a geometrical Embryo.:-> Please elaborate.:^)

      Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
      Douglas Adams, "Dirk Gently's Holistic Detective Agency"

      CPalliniC 1 Reply Last reply
      0
      • J jhwurmbach

        CPallini wrote:

        The following was mine

        Sorry, I am a geometrical Embryo.:-> Please elaborate.:^)

        Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
        Douglas Adams, "Dirk Gently's Holistic Detective Agency"

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        Well, the error isn't in geometry formula by itself. As an hint, in the following one the bug is fixed:

        ...
        double cosa = cos( alfa );
        double sina = sin( alfa );
        for (i = 0; i < POINTS; i++)
        {
        double dx = x[i] - x;
        double dy = y[i] - y;
        x[i] = x + dx * cosa - dy * sina;
        y[i] = y + dx * sina + dy * cosa;
        }

        :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

        In testa che avete, signor di Ceprano?

        L J 2 Replies Last reply
        0
        • CPalliniC CPallini

          Well, the error isn't in geometry formula by itself. As an hint, in the following one the bug is fixed:

          ...
          double cosa = cos( alfa );
          double sina = sin( alfa );
          for (i = 0; i < POINTS; i++)
          {
          double dx = x[i] - x;
          double dy = y[i] - y;
          x[i] = x + dx * cosa - dy * sina;
          y[i] = y + dx * sina + dy * cosa;
          }

          :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Sorry, that wasn't a horror, just a classical bug mixing present and future state. Lots of algorithms offer opportunities for mistakes like this one. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          this months tips: - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use PRE tags to preserve formatting when showing multi-line code snippets


          1 Reply Last reply
          0
          • CPalliniC CPallini

            Well, the error isn't in geometry formula by itself. As an hint, in the following one the bug is fixed:

            ...
            double cosa = cos( alfa );
            double sina = sin( alfa );
            for (i = 0; i < POINTS; i++)
            {
            double dx = x[i] - x;
            double dy = y[i] - y;
            x[i] = x + dx * cosa - dy * sina;
            y[i] = y + dx * sina + dy * cosa;
            }

            :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

            J Offline
            J Offline
            jhwurmbach
            wrote on last edited by
            #5

            Okayyyyy:doh: But when X[i] and y[i] are computed on different cores at exacty the same time...:~ :cool:

            Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
            Douglas Adams, "Dirk Gently's Holistic Detective Agency"

            C 1 Reply Last reply
            0
            • J jhwurmbach

              Okayyyyy:doh: But when X[i] and y[i] are computed on different cores at exacty the same time...:~ :cool:

              Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
              Douglas Adams, "Dirk Gently's Holistic Detective Agency"

              C Offline
              C Offline
              codemunkeh
              wrote on last edited by
              #6

              Then any good runtime will return an error stating quite plainly that: "Sorry. This method is busy. Please call again later."


              Ninja (the Nerd)
              Confused? You will be...

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups