math

QT Question (general math really): How can I tell if an Ellipse and a Line have an intersection?

The ellipse is actually a circle. I know all the coordinates of both things, I just need to know whether or not a line goes through an ellipse. Is this built in anywhere? SPecifically I am using QGraphicsEllipseIem and QLine but i can convert them to any other type thanks ...

Math Problem With Percentages

i'm terrible at math. trust me, you math experts will see why after reading my question. i have an object that is 300px in height. i need to calculate the percentage of that height where 90% = 300px (or the full height), 45% = 150px, 0% = 0px. so essentially, if i ask for 45% of the object's height, it will return 150px, or if i ask ...

Math Graph to Equation

Hi! Is there a tool which converts a graphical representation of an equation to that equation? (Graphical representation to aprox. math equation) ...

java random percentages

I need to generate n percentages (integers between 0 and 100) such that the sum of all n numbers adds up to 100. If I just do nextInt() n times, each time ensuring that the parameter is 100 minus the previously accumulated sum, then my percentages are biased (i.e. the first generated number will usually be largest etc.). How do I do t...

Need formula to calculate value

Possible Duplicate: Math - mapping numbers I have value "x" that can be from 0 to 127 and a value "y" that can be from -1000 to 0. I need to make that if x = 0 than y = -1000 and if x = 127 than y = 0... How can i make it? ...

Math - Displaying multiple objects in a single view using trigonometry

Hi there! It might be that my math is rusty or I'm just stuck in my box after trying to solve this for so long, either way I need your help. Background: I'm making a 2d-based game in C# using XNA. In that game I want a camera to be able to zoom in/out so that a certain part of objects always are in view. Needless to say, the objects mov...

Sample uniformly at random from an n-dimensional unit simplex.

Sampling uniformly at random from an n-dimensional unit simplex is the fancy way to say that you want n random numbers such that they are all non-negative, they sum to one, and every possible vector of n non-negative numbers that sum to one are equally likely. In the n=2 case you want to sample uniformly from the segment of the line ...

Sparse constrained linear least-squares solver

This great SO answer points to a good sparse solver for Ax=b, but I've got constraints on x such that each element in x is >=0 an <=N. Also, A is huge (around 2e6x2e6) but very sparse with <=4 elements per row. Any ideas/recommendations? I'm looking for something like MATLAB's lsqlin but with huge sparse matrices. I'm essentially try...

simplify expression k/m%n

hello. Simple question, is it possible to simplify (or replace division or modulo by less-expensive operation) (k/m)%n where variables are integers and operators are C style division and modulo operators. let me rephrase question slightly, except for case where variables are base2, under what conditions (e.g. some variable may be co...

How to find the angle of triangle in MATLAB

I'm trying to find the angle of the the triangle in MATLAB. e.g. in the triangle below, I want to find the angle of ABC (marked as black). if a = 40, b=50, How I can I find the angle (in degree) of ABC in MATLAB ? Thanks ...

question about complex values in java

We know that the general form of complex numbers is like this: z=a+i*b, where i is sqrt(-1). I have a question about how to express this in Java ? ...

A Plot Graph .NET WindowsForm Component Free

Hello All, I'm searching for a plot .NET component to plot a 2D line chart, given an array of data. It will be used with WindowsForm (C#) and It will be very helpful if it could be freeware. It is for a scientific application. This is my first asked question in stackoverflow, and excuse me for my terrible English written. ...

How to approximate double ?

How to I write a function that approximates a double in the following manner, returning an int: function (2.3) -> 2 function (2.7) -> 3 function (-1.2) -> -1 function (-1.7) -> -2 ...

maths: motion depending on time

hello, i have a mathematical problem: i have a function where the only parameter is the current time. the return should be a position which is used to place an object on a certain place. int position(int time) { int x = 0; //TODO implement x depending on time return x; } so basically the function is called every frame to put...

division problems

Possible Duplicate: Why does (360 / 24) / 60 = 0 in Java This line of code: System.out.println ("aray[j], "+aray[j]+", divided by sum, "+sum+", equals: aray[j]/sum: "+ aray[j]/sum) ; is yeilding this line of text: aray[j], 21, divided by sum, 100, equals: aray[j]/sum: 0 why is it doing this? (everything is right ec...

Determining polygon intersection and containment

I have a set of simple (no holes, no self-intersections) polygons, and I need to check that they don't intersect each other (one can be entirely contained in another; that is okay). I can check this by simply checking the per-vertex inside-ness of one polygon versus other polygons. I also need to determine the containment tree, which is...

How to create pulsating value from 0..1..0..1..0 etc for a given duration?

Hi I'm working on some code where I have a Time object with a member time. Time.time gives me the time since my application started in seconds (float value). Now I want to create a pulsating value between 0 and 1 and then from 1 to 0 again, which continues doing thins untill the application stops. I was thinking to use sin() but don't...

Solving Naked Triples in Sudoku

Hello, I wished I paid more attention to the math classes back in Uni. :) How do I implement this math formula for naked triples? Naked Triples Take three cells C = {c1, c2, c3} that share a unit U. Take three numbers N = {n1, n2, n3}. If each cell in C has as its candidates ci ⊆ N then we can remove all ni ∈ N from the other cells in...

Any way to specify the base of math.log() in javascript?

I need a log function in my javascript but it needs to be base 10, I can't see any listing for this so I'm assuming it's not possible... any math wizards out there know of an approach for this? Or maybe I'm missing something and there is a way? ...

Math Mod Containing Numbers

i would like to write a simple line of code, without resorting to if statements, that would evaluate whether a number is within a certain range. i can evaluate from 0 - Max by using the modulus. 30 % 90 = 30 //great however, if the test number is greater than the maximum, using modulus will simply start it at 0 for the remaining, w...