Rotation [modified]
-
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.
-
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.
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" -
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"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.
-
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.
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
-
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.
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" -
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"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...