Sphere

By BlueThen on May 16, 2009

I might release some documentation explaining all my algorithms. Don't know if anyone'd be interested though.
Image

;Sphere
;Made by BlueThen on May 16, 2009
;To install, paste this script in your Remotes (Alt + R)
;Then type /sphere or right click the channel or status and click "Sphere".
menu channel,status {
  Sphere: sphere
}
alias sphere {
  window -paoCzdk0 +tnbL @Sphere -1 -1 400 400
  set %sphere.a 0
  set %sphere.a2 0
  %sphere.t = 1
  %sphere.x = 15
  while (%sphere.x) {
    %sphere.y = 15
    while (%sphere.y) {
      hadd -m X %sphere.t %sphere.x
      hadd -m Y %sphere.t %sphere.y
      inc %sphere.t
      dec %sphere.y 
    }
    dec %sphere.x
  }
  set %sphere.tok tokenize 32 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 $&
    31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46  47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 $&
    67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97  98 99 100  $&
    101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 $&
    128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 $&
    156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 $&
    183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 $&
    211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 
  sphere.frame
}

alias -l sphere.frame {
  if ($window(@sphere)) {
    clear -n @sphere
    drawfill -n @sphere 1 1 1 1
    %sphere.tok
    scon -r .!drawdot -nr @sphere $!rgb( $!calc( 143+( $* /2)), $!calc( 143+( $* /2)), $!calc(143+ ( $* /2))) 1 $!sphere.iso( $!calc( (7.5- $!hget(Y, $* ))*15* $!cos( $!calc( $!hget(X, $* )*24+ %sphere.a )).deg), $!calc( 75* $!sin( $!calc( $!hget(Y, $* )*24)).deg), $!calc( (7.5- $!hget(Y, $* ))*15* $!sin( $!calc( $!hget(X, $* )*24+ %sphere.a )).deg)) 
    set %sphere.a $calc(100 * $sin(%sphere.a2).deg)
    inc %sphere.a2 4
    drawline @sphere
    .timer 1 0 sphere.frame
  }
  else unset %sphere.*
}
alias -l sphere.iso return $calc(($1 - $3)*0.866+200) $calc(($1 + $3)*0.5- $2 +200)

Comments

Sign in to comment.
WorldDMT   -  Jun 30, 2009

@knoeki: i dont speak english verry well but look at my comments

if u want u can use one comand for not use 2 like "inc" "dec" u can use "var"

so i told "if u want" and i never tell people how to do but that can learn u more
i was like u and i learn where is the problem?

anyway i'll comment always your post and if u wanna do like FordLawnmower no problem but read it before cz that can learn u somme thing and that's not bad :)

 Respond  
BlueThen   -  Jun 29, 2009

Hey. Lets not argue. I appreciate any feedback, especially WorldDMT\'s. Sure he sounds like a douche when he talks about it, but it\'s very constructive, if anything.

 Respond  
knoeki   -  Jun 28, 2009

[quote]WorldDMT should stop tooting his own useless horn and post a script

do u see any thing not good about my comments?[/quote]

yes. for example, constantly telling people how to do it differently. Seriously, even if you know it better, there's no need to keep telling people HOW to do it, you can also just give some tips or shut up, whatever suits you best.

Right now you just come across to me as a wiseass with an obession of proving his superiority.

 Respond  
WorldDMT   -  May 18, 2009

@tv3636

inc %sphere.t
dec %sphere.y

can be one commande also like this

var %sphere.t %sphere.t + 1,%sphere.y %sphere.y - 1

here we have one commande not 2 is a little faster wen i changed all that thing u can see the difference

the time of execution for his code is between 172 - 187 ticks or mine is 140 - 156

is faster :)

@FordLawnmower:

WorldDMT should stop tooting his own useless horn and post a script

do u see any thing not good about my comments?

 Respond  
tv3636   -  May 17, 2009

Alright, I wasn't aware they actually slowed things down. Regardless, having the var setting on one line versus two should not make a difference, should it?

 Respond  
FordLawnmower   -  May 17, 2009

I hate pipes. Thanks John Smith. That must have taken all of 5 minutes ;/

 Respond  
BlueThen   -  May 17, 2009

I found that pipes (|) can slow down your script drastically.

 Respond  
tv3636   -  May 17, 2009

inc %sphere.t
dec %sphere.y

can be one commande also like this

var %sphere.t %sphere.t + 1,%sphere.y %sphere.y - 1
How is that better in any way? The computer is still performing the same processes, you're just saving a line. You could also just do inc %sphere.t | dec %sphere.y but it doesn't matter at all.

 Respond  
JohnSmith   -  May 17, 2009

FordLawnmower: WorldDMT has posted a script. http://www.hawkee.com/snippet/6149/

 Respond  
BlueThen   -  May 17, 2009

Thanks for the feedback. I'll look into it, WorldDMT.

 Respond  
FordLawnmower   -  May 17, 2009

He's just picking at it with personal preferences, although I agree that you have to free the hashtables.
These 9 mile long workshops do nothing more than take away from the hard work that the actual scripter did. WorldDMT should stop tooting his own useless horn and post a script!!

 Respond  
^Neptune   -  May 17, 2009

Someone correcting BT's codes? Jesus christ.

 Respond  
WorldDMT   -  May 17, 2009

hi

for %sphere.a, and %sphere.a2

no need to set it 0 the "inc", and "set" command into alias sphere.frame will set it, and wen u close the windows, that will unset so u can remove it

for %sphere.t,%sphere.x, and %sphere.y set it local

var %sphere.t 1,%sphere.x 15,%sphere.y 15

for %sphere.tok u can do this

set %sphere.tok tokenize 32 $regsubex($str(.,225),/./g,\n $+ $chr(32))

and no need to set it, put it directly into the alias sphere.frame

if u want u can use one comand for not use 2 like "inc" "dec" u can use "var"

so

inc %sphere.t
dec %sphere.y

can be one commande also like this 

var %sphere.t %sphere.t + 1,%sphere.y %sphere.y - 1

and finaly dont forget to remove hash tables hfree x/y

so your code can be like this

menu channel,status {
  Sphere:sphere
}
alias sphere {
  window -paoCzdk0 +tnbL @Sphere -1 -1 400 400
  var %sphere.t 1,%sphere.x 15,%sphere.y 15
  while %sphere.x {
    while %sphere.y {
      hadd -m X %sphere.t %sphere.x
      hadd -m Y %sphere.t %sphere.y
      var %sphere.t %sphere.t + 1,%sphere.y %sphere.y - 1
    }
    dec %sphere.x
  }
  sphere.frame
}
alias -l sphere.frame {
  if ($window(@sphere)) {
    clear -n @sphere
    drawfill -n @sphere 1 1 1 1
    tokenize 32 $regsubex($str(.,225),/./g,\n $+ $chr(32))
    scon -r .!drawdot -nr @sphere $!rgb( $!calc( 143+( $* /2)), $!calc( 143+( $* /2)), $!calc(143+ ( $* /2))) 1 $!sphere.iso( $!calc( (7.5- $!hget(Y, $* ))*15* $!cos( $!calc( $!hget(X, $* )*24+ %sphere.a )).deg), $!calc( 75* $!sin( $!calc( $!hget(Y, $* )*24)).deg), $!calc( (7.5- $!hget(Y, $* ))*15* $!sin( $!calc( $!hget(X, $* )*24+ %sphere.a )).deg))
    set %sphere.a $calc(100 * $sin(%sphere.a2).deg)
    inc %sphere.a2 4
    drawline @sphere
    .timer 1 0 sphere.frame
  }
  else {
    unset %sphere.a*
    hfree x
    hfree y
  }
}
alias -l sphere.iso return $calc(($1 - $3)*0.866+200) $calc(($1 + $3)*0.5- $2 +200)
 Respond  
SumWon   -  May 17, 2009

"I might release some documentation explaining all my algorithms. Don't know if anyone'd be interested though."

I surely would be.

 Respond  
Prelude   -  May 16, 2009

Pretty neat BT, Not sure if i could even read your math skillz but you should post it for the hell of it.

 Respond  
Kirby   -  May 16, 2009

Hey BlueThen. Another cool snippet.
I've recently taken a brief look at trigonometry and I've gotten down some of the basics (cosine, sine, tangent, and their opposites); and yeah, it's quite interesting.
However, I haven't actually started making picture window animations/games yet, but they seem to be a fine challenge. :d
And to answer your question, I think it'd be a good idea to release your documentation of algorithms.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.