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


Groups > comp.lang.javascript > #38071

Re: Refreshing grade school math.

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Refreshing grade school math.
Date 2020-01-14 01:01 +0100
Organization PointedEars Software (PES)
Message-ID <7744077.NyiUUSuA9g@PointedEars.de> (permalink)
References (1 earlier) <qv6nnc$h44$1@gioia.aioe.org> <4ca72c7b-2cfd-4310-82d3-0fa8a917d889@googlegroups.com> <9c881808-2ee9-42c0-b964-b4f33f586b8a@googlegroups.com> <faff8a41-a0a7-4fb3-8a91-46b0f9801324@googlegroups.com> <aff0763d-eff8-46f2-ba60-0bcea3dcf5b0@googlegroups.com>

Show all headers | View raw


Michael Haufe (TNO) wrote:

> In elementary/primary school you should have learned the equation for a
> circle:
> 
> x^2 + y^2 = r^2
> 
> Alternate form to solve for y:
> 
> y = +/- sqrt(r^2 - x^2)
> 
> That's enough for you to plot your points.
> 
> Assuming a circle of radius 5 and centered at the origin (0,0)
> 
> iterate x from -r to +r and solve for y:
> 
> y = +/- sqrt((5)^2 - (-5)^2)
>   = +/- sqrt(25 - 25)
>   = +/- sqrt(0)
>   = +/- 0
>   = 0
> y = +/- sqrt((5)^2 - (-4)^2)
>   = +/- sqrt(25 - 16)
>   = +/- sqrt(9)
>   = +/- 3
> y = +/- sqrt((5)^2 - (-3)^2)
>   = +/- sqrt(25 - 9)
>   = +/- sqrt(16)
>   = +/- 4
> ...
> 
> now convert that to JavaScript

let r = 5;
document.body.appendChild(
  (new DOMParser()).parseFromString(
    `<svg xmlns="http://www.w3.org/2000/svg" width="${2 * r + 2}" 
height="${2 * r + 2}" stroke="black"><circle cx="${r + 1}" cy="${r + 1}" 
r="${r}" 
fill="transparent"/></svg>`,
    'image/svg+xml'
  ).documentElement
);

;-b

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | 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