Basicprogramming(.org) > Code and examples

Fun Shapes with Pedal Equation

<< < (3/3)

Aurel:

--- Quote --- but it looks like it represents all numbers between 0 and 2 * pi step 0.01.
--- End quote ---

Yes ..it looks that is range for some sort of ...let say loop
for example like this:

u=0
while u < (2*pi)
  'call function
  sf2d(n,a)
  u = u + 0.01 'incr u  / step
wend

function sf2d(n, a)
  'u = [0:.001:2 * pi];
  raux = abs(1 / a(1) .* abs(cos(n(1) * u / 4))) .^ n(3) + abs(1 / a(2) .* abs(sin(n(1) * u / 4))) .^ n(4);
  r = abs(raux) .^ (- 1 / n(2));
  x = r .* cos(u);
  y = r .* sin(u);
  plot(x, y);
end

..so i think that should be like above  ?
i must try..

But there is a problem with function arguments which are  what ?
it looks like array n(1) , a(1) ...
it seems to me like are sizes or dimensions of specific shape ?
hmm

 

Aurel:
ok i made 2 arrays for round rectangle shape

but compiler (o2) complain about abnormal error in abs(raux) ^
what loks strange to me ..hmmm


--- Code: ---float u , pi = 3.14592
int x,y,r
int a[2] , n[4]   ' set array sizes

'round rectangle shape ;
a[] = { 30 , 30 }   ' size 30 x 30 i guess...?
n[] = { 4, 12 , 15 ,15 }

while u < (2*pi)
  'call function for 2d plotting
  sf2d(n,a)
  u = u + 0.01 'incr u  / step
wend


function sf2d(n[], a[])
 
  raux = abs(1 / a[1] * abs(cos(n[1] * u / 4))) ^ n[3] + abs(1 / a[2] * abs(sin(n[1] * u / 4))) ^ n[4]
  r = abs(raux) ^ (- 1 / n[2])
  x = r * cos(u)
  y = r * sin(u)
  pset(win,x, y)
end function

--- End code ---

ZXDunny:
Given that ABS() should just return the argument with its sign stripped, it's hard to see what it could complain about :)

Aurel:
complain about power of abs() function

r = abs(raux) * (-1 / n[2]) - this work

but this one not:

r = abs(raux) ^ (-1 / n[2])

anyway this one draw something:

--- Code: ---function sf2d(int sfx, sfy)
   u = u + 0.01
   pset(win, sfx, sfy)
  raux = abs(a[1] * abs(cos(n[1] * u / 4)))* n[3]  +  abs(a[2] * abs(sin(n[1] * u / 4)))*n[4]
  r = abs(raux) * (-1 / n[2]) 
  x = sfx + r * cos(u)
  y = sfy + r * sin(u)
  pset(win, x, y)
 'circle(win , x, y, r+100)
end function
--- End code ---

Paul
I am looking fora mehod how to plot electric current density on metal surface...
Google throw me some images created in gnuOctave ,mathworks ,mathlab..etc
and one in python but that one plot using matlab ..so no directly in python using tcl/tk or pyPy
or something more closer to basic or C or pascal
so that i was trying all posible examples..around  ::)

Aurel:
This is what i want to plot
rectangular shape with sizes W,L
and current density  on specific frequency...

Navigation

[0] Message Index

[*] Previous page

Go to full version