math

Algorithm to compute a Voronoi diagram on a sphere?

Hi, I'm looking for a simple (if exists) algorithm to find the Voronoi diagram for a set of points on the surface of a sphere. Source code would be great. I'm a Delphi man (yes, I know...), but I eat C-code too. TIA Steven ...

List all possible combinations of k integers between 1...n (n choose k)

Hi, Out of no particular reason I decided to look for an algorithm that produces all possible choices of k integers between 1...n, where the order amongst the k integer doesn't matter (the n choose k thingy). From the exact same reason, which is no reason at all, I also implemented it in C#. My question is: Do you see any mistake in ...

Matrix Market into CRS conversion (sparse matrices)

When dealing with sparse matrices, how do I convert Matrix Market format into CRS (Compressed Row Storage)? ...

Need Better Algorithm for Finding Mapping Between 2 Sets of Points with Minimum Distance

Problem: I have two overlapping 2D shapes, A and B, each shape having the same number of pixels, but differing in shape. Some portion of the shapes are overlapping, and there are some pieces of each that are not overlapping. My goal is to move all the non-overlapping pixels in shape A to the non-overlapping pixels in shape B. Since the n...

WPF: Speed of Movement (Translation) varies with distance

With reference to this programming game I am currently building. I wrote the below method to move (translate) a canvas to a specific distance and according to its current angle: private void MoveBot(double pix, MoveDirection dir) { if (dir == MoveDirection.Forward) { Animator_Body_X.To = Math.Sin(Heading...

Simpson's Integral in Common Lisp

Hello all, I just wrote a simple Common Lisp program to find out Simpson's Integral: ;Integration by Simpson's rule; CL code ;Found to be working correctly with 'clisp' (defun simpsons(f a b n) (defparameter *summation* 0) (defvar *h* (/ (- b a) n)) (loop for k from 2 below (- n 1) by 2 do (setf *summation* (+ *summation* ...

WPF: Rendering a canvas at Random Points

With reference to this programming game I am currently building. When the game is started, I am generating these robots at supposingly random points on a Canvas, and at first look (adding one or two bots at the same time), this seemed to be working as it should. ...but, when I added a ton of bots at the same time, this is how they wher...

Simple algebra question, for a program I'm writing.

How would I solve: -x^3 - x - 4 = 0 You can't use quadratic, because it is to the 3rd power, right? I know I it should come out to ~1.3788 but I'm not sure how I would derive that. I started with: f(x) = x + (4/(x^2 + 1)). Solving for 0, moving the x over to the other side, multiplying by (x^2 + 1) on both sides, I end up wi...

How to connect two points in space with a curve of fixed length?

Exact duplicates: http://stackoverflow.com/questions/552184/how-do-i-connect-a-curve-of-fixed-length-between-two-points-in-space-using-matlab http://stackoverflow.com/questions/552226/how-to-connect-two-points-in-space-with-fixed-length-curve-using-matlab We are actually planning a Path between start and goal points for deformable l...

How to find sign of directed distance?

I have 2 points, P and Q, on a directed line AB in 3D space. They can be anywhere on the line, i.e. not necessarily between A and B. Pythagoras gives you the distance, obviously, but how do I calculate the sign of the directed distance from P to Q? Accepted answer: I was aware of Nick's solution, but I find it ugly because of the test...

Pathfinding on arbitrary non-rectangular bodies

I have various objects whose surfaces are 3D and non rectangular, such as spheres, pyramids, and various other objects represented by meshes. The mesh is not composed of polygons of equal size and distribution across the surface of the object, nor are they all semi/symmetrical objects like the ideal shapes of cylinders, spheres and cones...

Equation of a helix parametrized by arc length between two points in space

What is the equation of a helix parametrized by arc length (i.e. a function of arc length) between any two points in space? Is there any function for this ? How do i implement the same using matlab or mathematica ? ...

Mathematical problem: loop or recursive

I´m trying to break a number into an array of numbers (in php) in the way that for example: 25 becomes (16, 8, 1) 8 becomes (8) 11 becomes (8, 2, 1) I don´t know what the correct term is, but I think the idea is clear. My solution with a loop is pretty straightforward: $number = rand(0, 128); $number_array_loop = array();...

Plese help me write a function to determine if two numbers are nearly equal when rounded to n significant decimal digits

I have been asked to test a library provided by a 3rd party. The library is known to be accurate to n significant figures. Any less significant errors can safely be ignored. I want to write a function to help me compare the results: def nearlyequal( a, b, sigfig=5 ): The purpose of this function is to determine if two floating-point n...

WPF: Finding an element along a path (Not Yet Answered)

I have not marked this question Answered yet. The current accepted answer got accepted automatically because of the Bounty Time-Limit With reference to this programming game I am currently building. As you can see from the above link, I am currently building a game in where user-programmable robots fight autonomously in an arena. ...

How to generate a subdivided icosahedron?

I've asked some questions here and seen this geometric shape mentioned a few times among other geodesic shapes, but I'm curious how exactly would I generate one about a point xyz? ...

How do I calculate the average direction of two vectors

Hi, I am writing and opengl based iphone app and would like to allow a user to translate around a view based on the direction that they move two fingers on the screen. For one finger I know I could just calculate the vector from the start position to the current position of the users finger and then find the unit vector of this to get j...

Double precision problems on .NET

I have a simple C# function: public static double Floor(double value, double step) { return Math.Floor(value / step) * step; } That calculates the higher number, lower than or equal to "value", that is multiple of "step". But it lacks precision, as seen in the following tests: [TestMethod()] public void Fl...

Formula to determine whether a line form by 2 geo points (lat, lon) intersects geo region (circle)?

It does not need to be very accurate. Does anyone know a good way to do this? any help is much appreciated. ...

A way of checking if the digits of num1 are the digits in num2 without checking each digit?

Lets say I have guessed a lottery number of: 1689 And the way the lottery works is, the order of the digits don't matter as long as the digits match up 1:1 with the digits in the actual winning lottery number. So, the number 1689 would be a winning lottery number with: 1896, 1698, 9816, etc.. As long as each digit in your...