[Math] sin(), cos() not working? What special magic must I use to summon their powers?
site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:mime-version:subject:date:x-mailer; bh=3NBWVRghbHcpHfiW8fs5Az1v+KsQCkBO3tsUaInNrOQ=; b=JuGiAjO7u5P3L2+evigbncOK/vohQr5rQx97WpnOsXHwC2S+HDuY1T0BXZ0MVZRWHo HlAjXz9zrw0H8tMyyqF9fVR72dEC4kQWxl+sNZHwqzzV7EJlW2nwMk0fcupKQGkHQrlw Iy78hdumWlYEpK3jXe7vftKML4YbT0PRL3SEs= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:mime-version:subject:date:x-mailer; b=WDVEhM3JtYdqUt5pd7sllrKKJg8GX846+UIo7/TXFpPcPYsuW4pym6ruv53s2PitDk fi22aXwFWn7isZZTfVtswT8v+NaTQo2UNNXw8IGRuM/+7tAfjH8pCZar0PuEm2GCTkH1 mmLyf34aNMQKUTsSg+lJK+Q04KsGjrGB1XkIU= Hello, I am trying to convert the following from Javascript to Cocoa ObjC: return retVal; This is what I've got: float retVal; retVal = cornerSize*(1-cos(asin(i/cornerSize))); return (int)retVal; What what whaaaaat? I'm pretty stuck here, and would appreciate any help. Thanks Mike - - - Errors have occurred. We won't tell you where or why. Lazy programmers. - - - Charlie Gibbs _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.apple... var retVal = Math.round(cornerSize*(1-Math.cos(Math.asin(i/ cornerSize)))); Now retVal _must_ be an int, because the value is used as a margin attribute ("rounding" corners of divs). Variables i, cornerSize are passed to the function from a for loop. i being the counter for the loop, cornerSize being the size of corner desired by the user. Obviously, I'm no whiz at ObjC, and the fact that this keeps return '0' has got me stumped. At first I thought it was some stupid mistake I made translating the formula, but I tested a few things and now I'm not so sure. sin(90); returns 0 as well. When I use Apple's Calculator and ask it to tell me the result of sin(90), it gives me 1. Do I need to import something for this to work? Am I not tilting my head in the correct direction while typing my code? This email sent to site_archiver@lists.apple.com
participants (1)
-
Michael Robinson