I'd say, you need two points of the rectangle, make a line-equation between them and check whether the ballradius hits or not... I'll try to code that, don't expect too much by now.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu

cconv(q as double,s as uinteger) 'q = Number you'd like to convert
's = System to which you'd like to convert
dim as integer d,c
dim as double q
dim as string o,u,r(36),lz
declare function modulo(byval x as double,byval y as double) as double
for c=0 to 9
r(c)=str(c)
next
for c=asc("a") to asc("z")
r(c-asc("a")+10)=chr(c)
next
d=int(q)
q-=d
while modulo(q,1)<>0
q*=s
lz+="0"
wend
while q<>0 or d<>0
if q<>0 then
p=modulo(q,s)
o=r(p)+o
q=int(q/s)
elseif d<>0 then
q=modulo(d,s)
u=r(p)+u
d=int(d/s)
end if
wend
print u+"."+lz+o
function modulo(byval x as double,byval y as double) as double
return x-y*int(x/y)
end function
sleep
cconv(q as double,s as uinteger) 'q = Number you'd like to convert
's = System to which you'd like to convert
dim as integer d,c
dim as double q
dim as string o,u,r(36)
declare function modulo(byval x as double,byval y as double) as double
for c=0 to 9
r(c)=str(c)
next
for c=asc("a") to asc("z")
r(c-asc("a")+10)=chr(c)
next
d=int(q)
q-=d
while modulo(q,1)<>0
q*=s
wend
while q<>0 or d<>0
if q<>0 then
p=modulo(q,s)
o=r(p)+o
q=int(q/s)
elseif d<>0 then
q=modulo(d,s)
u=r(p)+u
d=int(d/s)
end if
wend
print u+"."+o
function modulo(byval x as double,byval y as double) as double
return x-y*int(x/y)
end function
sleep
I could store it as a string, or as a long integer base and a integer exponent, so, if I got that right, the simple formula is:
a=number to convert
b=basesystem
c=0 'exponent
output=returnstring
while a<>0
digit=a*base^c mod basesystem
c+=1
output=output+string(digit)
wend

'Simple "Neural Network" by psygate
'Solving the XOR-Problem, which can't be solved by a perceptron.
'At the moment... It's a very very stupid network and doesn't learn anything.
'
'Activation function is just a binary one. 0 or 1.
'Weights are chosen by random.
'2 input and 1 output neuron.
'Sorry for the shitty code!
randomize timer
option explicit
dim as integer a,b,c,d,t
const numofneuro=5
type neuron
pot as double 'Activation potencial
weight(numofneuro) as double 'Weight of Synapses to other neurons
threshold as integer 'Activation Threshold
end type
declare function process(a as ubyte,b as ubyte) as ubyte
dim shared as neuron n(numofneuro)
while t<>1
for a=1 to numofneuro 'Initialize every neuron
with n(a)
.pot=0 'Set potencial to 0
.threshold=.5 'Set an appropriate threshold
end with
for b=1 to numofneuro
if b<>a then
n(a).weight(b)=(-1)^int(rnd*2)*int(rnd*3) 'Initialize synapses weight.
else
n(a).weight(b)=0 'Prohibits loops from neuron1 to neuron1
end if
next b
next a
if process(0,0)=0 and process(1,0)=1 and process(0,1)=1 and process(1,1)=0 _
then t=1
wend
for a=1 to numofneuro
for b=1 to numofneuro-1
if b<>a then print n(a).weight(b)
next
next
sleep
function process(a as ubyte,b as ubyte) as ubyte
dim as integer l,m
n(1).pot=a
n(2).pot=b
for l=1 to numofneuro
for m=1 to numofneuro
n(m).pot+=n(l).weight(m)*n(l).pot
next
next
return n(numofneuro).pot
end function


I'd like to learn thew maths behind the magic of working with real big numbers, but the purebasic bigintlibreary could help me understanding that thing!

Page created in 0.279 seconds with 14 queries.