I'm writing a program to draw a three-dimensional cube (with a corner cut off) without using any 3D graphics APIs. The only API call I make is win32's SetPixel()
Everything is going great. I've drawn lines, faces, and even the entire cube. Then rotation came along.
For some reason, when I rotate my cube, it begins to shrink. I became confused, then I realised something. Floating point numbers are truncated.
Here's some code that is fired everytime the user presses 'X' on the keyboard.
Code:
p->setY( p->getY() * cos(5.0/180.0*PI) - p->getZ() * sin(5.0/180.0*PI));
p->setZ( p->getY() * sin(5.0/180.0*PI) + p->getZ() * cos(5.0/180.0*PI));
p is a Point object that I created. Here the Y value and the Z value of the Point are being set. The problem is everytime X is pressed, and this code is fired, a small amount of precision is lost. As a result, the cube shrinks.
I'm really completely stumped. I remember when studying assembler that floating point numbers can be truncated or rounded. I think rounding would solve my problem. Since 50% of the time the value would round up, and 50% of the time the value would round down.
Whereas with truncation values are always lost, and never gained.
Filename and Line Number Custom Error
I have a class, with a method that accepts 2 parameters. I would like to output error messages. So, lets say a new file is created, and my class is used in that file. We will call that file test.php
All possible combinations of String in PL/SQL
Hi All,
utf8_general_ci error ??
I have all kinds of data to be inserted in database table//I am getting this errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right
Do something every fifth time?
I'm trying to write a loop, but I want it to do something different after every fifth instance. Like, I want it do something like this:Quoteecho $a1;echo $a2;echo $a3;echo $a4;echo $a5.$b;echo $a6;And
php wont update my db
hello,sorry for posting in mysql forum but i dont know where exactly is the problem but here is the linkhttp://www.phpfreaks.com/forums/index.php/topic,272737.0.htm
mail with attachment problems
Hi. I have the following code:Code: else if(file_exists("site".$timp.".zip")) {$file=fopen("site".$timp.".zip", "rb"); $data=fread($file,
Problem!
I have another problem, when i run this code i get this error "Parse error: syntax error, unexpected T_ELSE in /home/a1408362/public_html/admin.php on line 41". I can't see why in the code
Storing/displaying image urls in a database?
HiBasically I have the following scenario:User chooses picture from list. Picture info is added into the db, including url.However I can't figure out how exactly i should be storing the url for the
PECL uploadprogress for php5.2
Hey, I just installed PHP5 via .htaccess on my 1and1 Shared Hosting Account.How would I exactly install the "PECL uploadprogress"?http://pecl.php.net/package/uploadprogress---There are
Clean URLs
Hi I was wandering if anyone has ever implemented URLs on their PHP run website using URLS like wikipedia does (i.e. http://en.wikipedia.org/wiki/Moodle)If so can you please help me learn how to setup