ID:154236
Mar 20 2002, 11:41 am
|
|
Does anyone out there have a proc that works like range, accept that it uses a circle formation instead of a square? I don't have a clue how to setup things using those mathmatical puzzles...
|
Mar 20 2002, 11:47 am
|
|
Gonna use that solar system idear? :P
|
Yep. My BasicMath library has exactly that. You can find it at AbyssDragon.TheAbyss.
That reminds me, however, that I need to get around to bugging Deadron into putting my libs back into DM.Library. -AbyssDragon |
Foomer wrote:
Does anyone out there have a proc that works like range, accept that it uses a circle formation instead of a square? I don't have a clue how to setup things using those mathmatical puzzles... This proc is for atoms, but you can easily convert it to your needs: sd_get_dist(atom/A, atom/B) /* Returns the mathematical 3D distance between two atoms. */ return sqrt((A.x - B.x)**2 + (A.y - B.y)**2 + (A.z - B.z)**2) |
Foomer wrote:
Does anyone out there have a proc that works like range, accept that it uses a circle formation instead of a square? I don't have a clue how to setup things using those mathmatical puzzles... Try this out: proc/crange(dist,atom/center=usr) I use dist*(dist+1) because odds are you don't want an exact distance check, but would like to round out the jagged edges of your circle a little better; if you don't, then the edges of the circle would always be points: x That's different from the way my routine would do it: xxx That's because if you're directly north/south/east/west, and move off to the side, the distance from center is suddenly sqrt(dist*dist+1), which would be over the limit. dist*(dist+1) is the nearest integer to (dist+0.5)**2, however. Lummox JR |
In response to Lummox JR
|
|
Oh! I misunderstood the question until I read your post, Lummox. I definately need to read closer.
|
In response to Lummox JR
|
|
That's because if you're directly north/south/east/west, and move off to the side, the distance from center is suddenly sqrt(dist*dist+1), which would be over the limit. dist*(dist+1) is the nearest integer to (dist+0.5)**2, however. It took me a couple minutes to figure out why the proc didn't contain sqrt() and round(). Pretty nifty! |
In response to Gughunter
|
|
Gughunter wrote:
That's because if you're directly north/south/east/west, and move off to the side, the distance from center is suddenly sqrt(dist*dist+1), which would be over the limit. dist*(dist+1) is the nearest integer to (dist+0.5)**2, however. Yeah, you don't need to work with square roots as long as you can work with squares. With integer math that helps a lot, and it's a good idea in any situation where you need to save time. I suspect this proc will be blasted inefficient as it is anyway. Lummox JR |
In response to Shadowdarke
|
|
That's okay, I found a use for yours, too :o)
|