Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need a math wiz (PAYING $USD FOR HELP)

Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
05-27-2007 09:45
I need someone who is good with math and I'm willing to pay well if you can help me, say $20 USD.

Generally, the problem is this: I need to be able to take X number of points in 3D space, <x,y,z>, and calculate smooth curves between the points. Additionally, I need to be able to plot new 3D coordinates at a variable distance along the path, say if I want to set the distance at 1m, or 5m, etc.

I know there's math out there that does this. But thats why Im willing to pay someone well if they can help me.
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
05-27-2007 09:57
Do you have only positions at each point, or do you have direction or velocity data as well?
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
05-27-2007 10:04
All I need are the 3D points, nothing else. I'm trying to read up on b-splines and bezier curves now, but its honestly a bit over my head.
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
05-27-2007 10:18
No, I'm not asking what you want out of the algorithm, I'm asking what you're putting in. If you have velocity data at each point then you can make a nice smooth curve (I've got something that does that already), if you don't then I think the problem might be under-determined. Hmm, I think you'd need to use data of the 2 points ahead and the 2 points behind the segment of path.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
05-27-2007 10:25
my problem set is like this: I will generate X number of points in 3D space, like say between prims I rez out. I want then want to be able mathematically generate a smooth curved path using those initial points, like http://web.cs.wpi.edu/~matt/courses/cs563/talks/curves.html
Domino Marama
Domino Designs
Join date: 22 Sep 2006
Posts: 1,126
05-27-2007 13:16
Easiest way is to use interpolation. There's a number of different ways to do it depending how how accurate you want to be. http://csounds.com/ezine/summer2000/internals/ has a good explanation of some options. Here's an old sinc implementation I did in C++, should be enough for someone to run with a conversion to LSL. You'd have to do X, Y and Z co-ords seperately.

CODE

void Module::sincInter(float *input, int input_size, float *output,int output_size)
{
int i, j;
float o, x;
for( i=0; i < output_size; i++)
{
x = (i * (float)input_size) / (float)output_size ;
o = 0.0f;
for( j = 0; j < input_size; j++)
{
if( j == x )
o += input[j];
else
o += sin(PI*(j-x)) / (PI*(j-x)) * input[j];
}
output = o;
}
}


Actually, I'll knock up an LSL version.. Back in few..
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
05-27-2007 13:31
I am interested in low computation heuristical approaches. sort of like how a baseball player runs the bases...

If it is a single, run straight at the first base.
if it might be more than a single, veer to the right (away from second base) so that when you reach first base you will have already started the turn to second.
Continue for each base...



So, in 3D. Call the next two points on the list First and Second.

Heading toward the First point.
Determine where the Second is. Veer away from it a little now to smooth out the turn.
If the turn will be sharp, slow down, else speed up.
Head toward the First Point.

repeat until done...

I babble...it's fun.
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
05-27-2007 13:35
From: Geuis Dassin
All I need are the 3D points, nothing else. I'm trying to read up on b-splines and bezier curves now, but its honestly a bit over my head.


Geuis, Seifert is telling you that the points are not enough. There are an infinite number of smooth paths thru a set of points.

On the other hand, if you say that at the last point, the path has to be going due East at 5 meters/second, that changes everything. Or maybe the path should be as short as possible, or maybe the speed should be 1 m/s all the time, and the total trip should take 60 seconds. These additional factors will change the answer.

Maybe it would help if you told us what the thing is...a hummingbird will pass thru the points differently than a hawk.
Domino Marama
Domino Designs
Join date: 22 Sep 2006
Posts: 1,126
05-27-2007 13:54
CODE

list sincInter( list input, integer output_size )
{
list output = [];
integer i;
integer j;
float o;
float x;
integer input_size = ( input != [] );
for( i=0; i < output_size; i++)
{
x = (i * (float)input_size) / (float)output_size ;
o = 0.0;
for( j = 0; j < input_size; j++)
{
if( j == x )
{
o += llList2Float( input, j );
}
else
{
o += llSin(PI*(j-x)) / (PI*(j-x)) * llList2Float( input, j );
}
}
output = ( output = [] ) + output + [ o ];
}
return output;
}

default
{
state_entry()
{
llSay(0, llDumpList2String( sincInter( [ 10.0, 12.0, 7.0, 20.0, 1.0 ], 15 ), ", " ));
}
}


This was actually originally written for audio, until I saw the output, didn't remember it would continue the interpolation past the end point. Depends on application how best to handle this so I'll leave for now.

Just feed it a list of all the Y co-ordinates and tell it how many points you want back.. Repeat for X & Z. The example above returns:

10.000000, 14.066406, 14.891788, 12.000001, 7.546314, 5.080103, 7.000000, 12.593926, 18.276554, 20.000000, 16.096838, 8.427813, 1.000000, -2.837224, -2.482324

can tell it's been over 4 years since I last looked at this code.. thought it was wrong for a moment. changing it to return 50 values give the following:

9.999999, 11.438580, 12.720934, 13.776106, 14.543041, 14.975723, 15.047495, 14.754171, 14.115611, 13.175619, 12.000000, 10.672933, 9.291783, 7.960750, 6.783717, 5.856901, 5.261747, 5.058687, 5.282206, 5.937647, 6.999999, 8.414840, 10.101395, 11.957488, 13.866149, 15.703287,17.346024, 18.680962, 19.611866, 20.066200, 20.000000, 19.400751, 18.288107, 16.712337, 14.750699, 12.501999, 10.079706, 7.604214, 5.194819, 2.961893, 1.000000, -0.617761, -1.843641, -2.657225, -3.065370, -3.100237, -2.815531, -2.281387, -1.578294, -0.790595

So the interpolation can go above the actual values to shape the curve.

Not entirely sure of best way to approach equidistant points. I'll have a think and get back to you.

Had a think, no simple solution I can think of. Knowing the application will make things easier to think through. If you are thinking of rezzing markers then perhaps constraining them to be a set distance from each other is best approach. Assuming this lookup table generation approach will work for you ;)