math

2D Spaceship movement math

Hi, I'm new here. I'm trying to make a top-down spaceship game and I want the movement to somewhat realistic. 360 degrees with inertia, gravity, etc. My problem is I can make the ship move 360° with inertia with no problem, but what I need to do is impose a limit for how fast the engines can go while not limiting other forces pushing/p...

Choosing circle radius to fully fill a rectangle

Hi, the pixman image library can draw radial color gradients between two circles. I'd like the radial gradient to fill a rectangular area defined by "width" and "height" completely. Now my question, how should I choose the radius of the outer circle? My current parameters are the following: A) inner circle (start of gradient) center p...

comparing two angles

Given four points in the plane, A,B,X,Y, I wish to determine which of the following two angles is smaller ∢ABX or ∢ABY. The angle ∢ABX is defined as the angle of BX, when AB is translated to lie on the open segment (-∞,0]. Intuitively when saying ∢ABX I mean the angle you get when you turn left after visiting vertex B. I'd rather not ...

An algorithm for converting a base-10 number to a base-N number.

Guys, I am looking for a way to convert a base-10 number into a base-N number where N can be large. Specifically i am looking at converting to base-85 and back again. Does anyone know a simple algorithm to perform the conversion? Ideally it would provide something like: to_radix(83992, 85) -> [11, 53, 12] Any ideas are appreciated! ...

Required Working Precision for the BBP Algorithm?

Hello, I'm looking to compute the nth digit of Pi in a low-memory environment. As I don't have decimals available to me, this integer-only BBP algorithm in Python has been a great starting point. I only need to calculate one digit of Pi at a time. How can I determine the lowest I can set D, the "number of digits of working precision"? ...

6^x = 5 equation, how to solve it?

If it would be 6^x = 1 or 6^x = 6 or 6^x = 36 it would be extremely easy, but how to solve this equation: 6^x = 5 I don't need an answer, I want to find out how to solve equations like this one, I need solution. Thanks. ...

Suggestions on syntax to express mathematical formula concisely

Hello. I am developing functional domain specific embedded language within C++ to translate formulas into working code as concisely and accurately as possible. I posted a prototype in the comments, it is about two hundred lines long. Right now my language looks something like this (well, actually is going to look like): // implies tw...

High speed matrix manipulation in c#?

I'm working on some image manipulation code in c# and need to do some matrix operations (specifically 2D convolution). I have the code written in matlab which uses the conv2 function ... is there a library for C# / .NET that does good high-speed matrix manipulations? I'd be fine if it requires some specific GPU and does the matrix math...

Algorithm to determine the minimal set of coins you should carry to always make exact change

US coin values: .01, .05, .10, .25 (*) What is an algorithm to determine what configuration(s) of US coins can be used to match every value from .01-.99 using the fewest coins possible? ...

How would you solve this graph theory handshake problem in python?

I graduated college last year with a degree in Psychology, but I also took a lot of math for fun. I recently got the book "Introductory Graph Theory" by Gary Chartrand to brush up on my math and have some fun. Here is an exercise from the book that I'm finding particularly befuddling: Suppose you and your husband attended a party w...

what is the difference between round() & trunc() function?

I am very confused about these functions? ...

Scientific Algorithms that can produce imagery, pseudocode perhaps?

Hello, I have a client who is based in the field of mathematics. We are developing, amongst other things, a website. I like to create a mock-up of a drawing tool that can produce some imagery in the background based on some scientific algorithms. The intention being that the client, later, may create their own. (They use emacs for every...

Derivative Calculator

Hi! I'm interested in building a derivative calculator. I've racked my brains over solving the problem, but I haven't found a right solution at all. May you have a hint how to start? Thanks I'm sorry! I clearly want to make symbolic differentiation. Let's say you have the function f(x) = x^3 + 2x^2 + x I want to display the derivative...

Simulate a spray

How can i simulate a spray like windows paint ? i think it create points random , what is your opinion? ...

Opposite method of math power adding numbers

I have method for converting array of Booleans to integer. It looks like this class Program { public static int GivMeInt(bool[] outputs) { int data = 0; for (int i = 0; i < 8; i++) { data += ((outputs[i] == true) ? Convert.ToInt32(Math.Pow(2, i)) : 0); }...

Single dimension peak fitting

I have a single dimensional array of floating point values (c# doubles FYI) and I need to find the "peak" of the values ... as if graphed. I can't just take the highest value, as the peak is actually a plateau that has small fluctuations. This plateau is in the middle of a bunch of noise. I'm looking find a solution that would give me t...

Javascript returns Nan in IE, FF ok

im very new to javascript, and writing this script to add up a shopping cart and print out subtotals and totals. it works in FF but not in IE. this function is called by onclick of one of three select options with a value of 0-25. it is in a js file called in the head. what it does is get the selected values as variables, parseint the...

Step math function

Hi I need function which returns: for any number from range => result [0.001,0.01) => 0.01 [0.01,0.1) => 0.1 [0.1,1) => 1 [1,10) => 10 [10,100) => 100 etc. My first idea was to use if, but this the worst way. Is there a simple solution? ...

Faster way to compare two sets of points in N-dimensional space?

List1 contains a high number (~7^10) of N-dimensional points (N <=10), List2 contains the same or fewer number of N-dimensional points (N <=10). My task is this: I want to check which point in List2 is closest (euclidean distance) to a point in List1 for every point in List1 and subsequently perform some operation on it. I have been do...

Workflow to resize and crop an image weighted on coordinate

Hi! I'm working on a resize and crop workflow to allow images to be resized and then cropped to a specific size. Normally one resize the smallest dimension to fit the destination size, and then crop to get eg. a square. However, in this case, I have some additional face-detection data: face_x, face_y and face_width and face_height. The...