An additional closing bracket might be useful too...
Cthulhu
@Cthulhu
Best posts made by Cthulhu
Latest posts made by Cthulhu
-
RE: Ensure that any deallocated pointers are set to NULL
-
RE: Trick Interview Questions
One of my favorites is, "How do you divide your time between planning and coding?"
They typically start by giving me all sorts of percentages. Like, "I spend 85% planning and 15% coding."
What they don't know is the answer that *I* expect to hear is 100% coding. I don't want the people under me thinking. I want coders. Don't plan, just code. I don't pay you to think.
Thats so stupid I feel like hitting the "Report abuse" button
-
RE: I try to help these kids, I really do.
I also constructed a long, witty, informative post on this very subject but lost it when my computer magically rebooted
-
RE: ISPs and Port 25
@Albatross said:
My question is: How common is this blocking of Outbound Port 25? Is there anything I can do about it?
You could either drop a logic bomb through their back door, or you could use hotmail.
How do they get away with this sort of thing?
It's just another example of the Sad Age We Live In
-
RE: Next generation laptop
I wonder how many cycles per second it can achieve
-
RE: Difference of two angles without branching
I am writing a simple mechanical simulation program in C(++). The problem is as follows: given two vectors, compute the angle between those vectors AND make sure it is within the allowed range of results: (-M_PI; M_PI). For now, I am using a rather obvious solution:
If you have two vectors already, then as someone else suggested use dot product of those two vectors. That can be a faster, and simpler method and you get none of this clamping issue.
First you have to normalize the vectors by dividing their components by their length.
v1 = v1 / v1.length()
v2 = v2 / v2.length()
Then when you get the dot product of them:
float dotproduct = v1.x * v2.x + v1.y * v2.y
dot product now holds cos A, where A is your angle. If you really need A in radians or degrees then you will have to use inverse cosine to get it. But for most purposes you should be able to just use that value (for example if you need the angle to test whether two vectors are within 45 degrees of one another then the test would be if (dotproduct < cos(45), or dotproduct < 0.707) with no need to convert to radians or degrees)
The only expense involved here is calculating the length of a vector which requires a square root, but I assume that's better than using an atan2.
Also if you don't like having to normalize the vectors I believe you can accomplish the same thing doing:
cos A = (v1 dot v2) / (v1.length()*v2.length())
If you have your lengths cached from elsewhere then you are laughing. You have an angle (in cos A form) using just one division, three multiplications and 2 additions.
-
RE: Maybe *this* will help...
Actually she may have been right.
An activeX control could be written which stored "water" and "land" as seperate bitmasks then determined whether an application could be opened depending on whether the icon fell on water or land. The idea being that you could "lock" applications by dragging them into the water. Im not saying this was the case, but it was a good idea to move the icon back onto land - worth a try.