Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #38011

Refreshing grade school math.

Newsgroups comp.lang.javascript
Date 2020-01-08 23:54 -0800
Message-ID <8fe5af4b-242f-460f-b546-4a2ed830d1eb@googlegroups.com> (permalink)
Subject Refreshing grade school math.
From Jonas Thörnvall <jonas.thornvall@gmail.com>

Show all headers | View raw


I decided to try make a function to draw a circle "polygon" without angles. But i have completly forgotten howto evenly distribute the cordinates without using sin cosin angle.

Below is the circle/polygon divided into four quadrants and arched. But it does not create a regular polygon. Simple fact my math skills lacking. Before i decided to graph equation, i first did try solve the cordinates using purely geometric approach. No angles just finding cross sections of shape, couldn't do it.

But maybe someone with a little more math insight have an idea howto create regular polygons without cosin and sin angle?

Distance is "sort of" vertex distance but it is not regular.

function circle(){
translateX=800;
translateY=450;
radius=400;
x=400;
distance=150;
arclength=280;
//x*x+y*y=400*400  solve y
for (x=-arclength;x<=arclength;x=x+distance){
ysquare=(radius*radius)-(x*x);
y=Math.sqrt(ysquare);
if(x==-arclength){savex=x;savey=y;}
ctx.fillStyle="black";
ctx.lineTo(x+translateX,y+translateY);
//ctx.fillRect(x+translateX,y+translateY,4,4); 
}
for (y=arclength;y>=-arclength;y=y-distance){
xsquare=(radius*radius)-(y*y);
x=Math.sqrt(xsquare);
ctx.lineTo(x+translateX,y+translateY);
//ctx.fillRect(x+translateX,y+translateY,3,3); 
}
for (x=arclength;x>=-arclength;x=x-distance){
ysquare=(radius*radius)-(x*x);
y=Math.sqrt(ysquare);
ctx.lineTo(x+translateX,-y+translateY);
//ctx.fillRect(x+translateX,-y+translateY,3,3); 
}
for (y=-arclength;y<=arclength;y=y+distance){
xsquare=(radius*radius)-(y*y);
x=Math.sqrt(xsquare);
ctx.lineTo(-x+translateX,y+translateY);
//ctx.fillRect(-x+translateX,y+translateY,3,3); 
}
ctx.lineTo(savex+translateX,savey+translateY);
ctx.fillStyle="yellow";
ctx.stroke();
}

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-08 23:54 -0800
  Re: Refreshing grade school math. "R.Wieser" <address@not.available> - 2020-01-09 09:19 +0100
    Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-09 00:34 -0800
      Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-09 00:43 -0800
        Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-09 00:44 -0800
    Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-11 05:09 -0800
      Re: Refreshing grade school math. Julio Di Egidio <julio@diegidio.name> - 2020-01-11 22:13 -0800
        Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-13 09:58 -0800
          Re: Refreshing grade school math. Julio Di Egidio <julio@diegidio.name> - 2020-01-13 10:16 -0800
            Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-13 11:16 -0800
          Re: Refreshing grade school math. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-13 12:22 -0800
            Re: Refreshing grade school math. Julio Di Egidio <julio@diegidio.name> - 2020-01-13 12:53 -0800
              Re: Refreshing grade school math. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-13 15:31 -0800
              Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-13 16:03 -0800
            Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-13 13:00 -0800
              Re: Refreshing grade school math. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-01-13 15:35 -0800
                Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-13 15:43 -0800
            Re: Refreshing grade school math. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-01-14 01:01 +0100
              Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-13 16:07 -0800
        Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-13 10:01 -0800
        Re: Refreshing grade school math. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-01-13 10:04 -0800

csiph-web