Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to curve a matrix?

Author
Message
AzureZeal
23
Years of Service
User Offline
Joined: 10th May 2003
Location:
Posted: 11th Jul 2003 11:39
Im trying to get my matrix to do a real dome/sphere curve, but keep running into problems. Even when I use a true curved height value (using newyvalue()) the curve ends up looking almost like a straight slant. Anyone have any code of a real matrix curve, or any advice that might help?

Thanks in advance
The Darthster
23
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 11th Jul 2003 12:45
You can use a sine wave to make a curved matrix:



This is actually a sin^2 graph, but you can see what it's doing.

Once I was but the learner,
now, I am the Master.
David T
Retired Moderator
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 11th Jul 2003 13:04
You could create a matrix with a block of height (a few tiles higher than the rest), then smooth it off to make it look curvy.

To smooth a matrix, go through each tile and take the average of the hieghts of all its surrounding tiles. Then set the current tile to that average.

You are the th person to view this signature.
GRAVITY: I fought the law but the law won
AzureZeal
23
Years of Service
User Offline
Joined: 10th May 2003
Location:
Posted: 12th Jul 2003 02:15
Thanks a ton darth that looks like its just what I need. But im having a little trouble getting a custom sized curve to work. I get the start and finishing coords into a/b, and Im dividing the number of xsteps and zsteps by 180, but for some reason the curve seems be dipping back down at the end (looks more like a wave than a curved hill). Any idea what I might be doing wrong at the end? Heres the code...

a# = (180.0/xsteps)
b# = (180.0/zsteps)

for a = firstx to lastx
for b = firstz to lastz
set matrix height 1,a,b,sin(a*a#)*sin(b*b#)*height#
next b
next a

You mentioned something about a sin^2 graph? Does that have something to do with the wave im getting?

AzureZeal
23
Years of Service
User Offline
Joined: 10th May 2003
Location:
Posted: 12th Jul 2003 06:29
Figured out what I was doing wrong. Because the sin is assuming a and b will start at 0, when I tryed to make a curve anywhere besides 0,0, the curve would be all messed up. Here is how I solved it if youd like to know...

a# = (180.0/xsteps)
b# = (180.0/zsteps)

tester = 0: tester2 = 0
for a = firstx to lastx
for b = firstz to lastz
set matrix height 1,a,b,sin(tester*a#)*sin(tester2*b#)*height#
inc tester2
next b
tester2 = 0: inc tester
next a

Thanks again darth, looks great

The Darthster
23
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 12th Jul 2003 12:05
No problem.

Once I was but the learner,
now, I am the Master.

Login to post a reply

Server time is: 2026-07-21 12:49:03
Your offset time is: 2026-07-21 12:49:03