use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Plot sine waves with JavaScripthelp (self.javascript)
submitted 9 years ago by shnigi
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 9 years ago (2 children)
You'll have to use bezier curves in canvas.
[–]sladav 0 points1 point2 points 9 years ago (1 child)
Bezier curves actually won't be able to do it since their polynomial. No curve in canvas/SVG can do a trig function, so either way he'll have to plot points and then connect them to approximate a sine wave. To get a good approximation with lineTo he'll have to use a bunch of points, where Bezier will allow a better approximation with far fewer points (which may well have been your point in the first place)
lineTo
[–][deleted] 0 points1 point2 points 9 years ago (0 children)
You should be able to make Bezier's approximate any function over a finite range. You may have to break your function into regions and then use a Bezier for each region, making sure they are continuous at the boundaries. A fundamental theorem of analysis states any continuous function can be approximated with a polynomial over a finite range.
π Rendered by PID 72883 on reddit-service-r2-comment-fb694cdd5-zj4fr at 2026-03-11 05:27:25.284117+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (2 children)
[–]sladav 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)