Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

- - - - -

Bug on complex division


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 CMRM   Members   -  Reputation: 109

Like
1Likes
Like

Posted 13 July 2012 - 12:25 PM

I just found a small bug in the complex division operation that is available in the scriptmath addon. In scriptmathcomplex.cpp the division is defined like this:
Complex Complex::operator/(const Complex &other) const
{
float len = other.length();
if( len == 0 ) return Complex(0,0);
Complex res((r*other.r + i*other.i)/len, (i*other.r - r*other.i)/len);
return res;
}

when it should be
Complex Complex::operator/(const Complex &other) const
{
float squaredLen = other.squaredlength();
if( squaredLen == 0 ) return Complex(0,0);
Complex res((r*other.r + i*other.i)/squaredLen, (i*other.r - r*other.i)/squaredLen);
return res;
}


And of course, you have to define the function squaredlength:
float Complex::squaredlength() const
{
return r*r + i*i;
}

And then works fine.

I've been using Angelscript in my fractal generating app and it works nicely, and the process of integrating it was painless thanks to it's clean API and good documentation. Thanks a lot for your work!

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 2312

Like
0Likes
Like

Posted 13 July 2012 - 01:14 PM

Thanks. I'll have this corrected.

I just created the complex type for the add-on to provide a simple example on a value type. I haven't really tested it to make sure it performing the proper math calculations. Posted Image
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 Andreas Jonsson   Moderators   -  Reputation: 2312

Like
0Likes
Like

Posted 13 July 2012 - 05:51 PM

Checked in under revision 1362
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS