math

Scaling Arbitrary oriented and dimensioned 3D boxes for force no intersection

Hi all, I have a set of 3D boxes with arbitrary dimensions, translations and rotations. I need to force the boxes not to intersect by scaling them by a single constant over their 3 dimension components. At the moment I am doing this iteratively by checking for intersection and then reducing the scaling iteratively until there is no i...

Quaternion and three axes

Given a quaternion q, and three 3D vectors (vx, vy, vz) which form coordinate axes, which can be oriented in arbitrary direction, but are all perpendicular to each other, thus forming a 3d space. How can I check if the quaternion q is rotated to the same direction (or opposite direction) as some of the 3D vectors (vx, vy, vz)? ...

Is it possible to predict if a mathematical operation would result in an overflow?

Say you have 2 numbers, for each typical mathematical operation is it possible to predict (without significant overhead) whether those operations would result in an overflow of the type which those numbers are currently represented as? ...

What's wrong with my project and unproject functions?

I'm using OpenTK for a game in C#, and it doesn't come with the project and unproject functions, which convert between world and screen coordinates. Well, it does, but they're deprecated and I couldn't get them to work. I took a shot at implementing them myself based on the opengl spec (see left hand menu, gluProject and gluUnProject, an...

Object quaternion parallel or perpendicular to all basis vectors

Given an object quaternion q, and basis vectors vx, vy, vz forming a 3D space, how can I check whether the quaternion is parallel or perpendicular to all of the basis vectors? For example, I have basis vectors: vx = (0.447410, 0, -0.894329) vy = (0, 1, 0) vz = (0.894329, 0, 0.447410) and quaternion q(w,x,y,z) = (-0.973224, 0, -0.22986...

finding a/b mod c

I know this may seem like a math question but i just saw this in a contest and I really want to know how to solve it. We have a (mod c) and b (mod c) and we're looking for the value of the quotient (a/b) (mod c) Any ideas? ...

Is it possible to learn math from scratch and how ?

I have a quite big development experience and I wonder is it possible to start learning math from scratch. I forgot almost everything I know, even school program. Please give me some guidance on this. Where to start what to do. Are there any math books for developers. May be with exercises to write code or experiment, etc... Any help i...

How to write out algorithms?

Does anyone know of a basic beginners tutorial on how to read mark up like this notation when talking about algorithms or what this type of markup is officially referred to as so I know what to google for? taken from here. ...

Determine if a set of points is a polygon

Given a set of points in 2D the resulting polygon can be convex, concave or 'not a polygon'. The definition that I am using for 'not a polygon' is that the line connecting two points crosses another 'polygon' line. I know about taking the dot product (Green's Theorem?) to show convexity and concavity of a polygon. I know that the sum of ...

Calculating Binomial Coefficient (nCk) for large n & k

Hi everyone! I just saw this question and have no idea how to solve it. can you please provide me with algorithms , C++ codes or ideas? This is a very simple problem. Given the value of N and K, you need to tell us the value of the binomial coefficient C(N,K). You may rest assured that K <= N and the maximum value of N is 1,000,000,...

20 bit integer math

How do I add/subtract/multiply and divide integers using only 20 bits instead of 32 bits in C#? Will these operations be faster than 32bit precision? For example this .NET library is featuring 20 and 30 bit arithmetic with different speeds: http://complex-a5.ru/polyboolean/index.html Thanks. ...

_matherr does not get called when built into a DLL

I have a basic solution file (.sln) where I was able to reproduce a problem I have been facing recently. It contains 3 projects: 1.) MathTest.lib - containing methods that might cause a mathematical error, like acos(1.1). 2.) MathTestDll.dll - calls the methods from the above lib. 3.) UnitTest.exe - calls the exported method in the DLL ...

Independent set in a graph

As you know finding maximum independent set is NP. Is there an algorithm to find out whether a given graph has an Independent set of at least k vertices? Note that we don't want to find it. We just want to find out if such thing exists. ...

What Mathematical Technique is used to compare algorithm complexity?

Hi all I started reading 'Introduction to Algorithms' today, but I've gotten a bit confused over one of the exercises. Exercise 1.2.2 asks the reader Suppose we are comparing implementations of Merge sort and Insertion Sort on the same machine. For inputs of size n, insertion sort runs in 8n^2 steps, while merge sort runs in...

How does a 32-bit operating system perform the 2^56 modulo 7 ?

How does the system perform the 2^56 modulo 7, if it's 32 bits operating system in cryptography for example? And how it stored in memory? ...

How to compute compounded interest rate ?

I have the following scenario where i invest variable amount of principal every month, Investment Month $300 Jan $200 Feb $100 Mar and i get a return of, Returns Month $1000 Apr How do i calculate the nominal annual interest rate if the amount is compounded monthly? ...

C++: simple question about random number function

Possible Duplicate: Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7 I was asked a simple question (purely in interest), in it there's a function which supplies a random number between 1 and 6, now with based off that function you need to...

API for mathematical calculations on the cloud

Is there any service that provide a public API to perform mathematical calculations (such as linear algebra decompositions etc)? Thanks ...

Objective C : calculate and display time to millisecond

Full Disclosure: I am a mathematical moron int hours = totalSeconds / (60 * 60); int minutes = (totalSeconds / 60) % 60; int seconds = totalSeconds % 60; //int milliseconds ??? calculatedExposureTime.text = [NSString stringWithFormat:@"%02d:%02d:%02d:%02d", hours, minutes, seconds, milliseconds]; Say totalSeconds was a fraction of a s...

Secant method of iteration into PHP

How would i turn the secant method of iteration into php? The formula is xi+1= xi - (f(xi) (xi-xi+1))/f(xi)-f(xi-1) where f = function and i is an iteration. so xi+1 is the next iteration after xi So far I have seen this, but there is somethning wrong somewhere in it so i want to make one from scratch, unless someone here can see wha...