Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSetPos and Math Errors....

Luciftias Neurocam
Ecosystem Design
Join date: 13 Oct 2005
Posts: 742
05-15-2006 19:50
hi...has anyone else run across this problem: I'm attempting to create a non-physical swarm script for some animals I'm working on. it works reasonably well, but periodically seems to generate math errors. I can't figure out where i have values that are turning complex.

the error is somewhere in the following lines of code (within a sensor event):
CODE

if( llVecMag(direc)>3)
{
llSetPos(<mypos.x+mult*INC*direc.x,mypos.y+mult*INC*direc.y,gz+zshift>);
}
if(llVecMag(direc)<=1)
{
llSetPos(<mypos.x+-mult*INC*direc.x,mypos.y+-mult*INC*direc.y,gz+zshift>);
}



where direc is the target direction for the object in the swarm.

how, exactly, can llVecMag be producing complex values, unless the positional numbers going in are themselves complex.
Llauren Mandelbrot
Twenty-Four Weeks Old.
Join date: 26 Apr 2006
Posts: 665
05-15-2006 20:38
I`d like to suggest that you ask people in the Artificial Life forum.

Toodle-oo!
Jigsaw Partridge
A man of parts
Join date: 3 Apr 2005
Posts: 69
05-15-2006 21:37
Math errors are usually divide-by-zeros - can't quite see how this would be happening in the fragment you show. I would suggest loading the new position into a vector variable first, though, and passing this to llSetPos(), rather than doing the whole calculation within the function call argument list. This would simplify the logic for the LSL interpreter, and also allow you to print out the new vector position value, just to check it is what you expect.
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
05-16-2006 01:58
Yeah, llVecMag shouldn't be giving math errors. Get some readouts of the values going in, see if you can track it down.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG