Coder Social home page Coder Social logo

benjaminfox1 / sin_cos_orbit Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 874 KB

Simple Illustration of Sin and Cos (credit Pythagoras et al)

License: MIT License

HTML 0.01% JavaScript 99.99% CSS 0.01%
p5js-animation p5js-sketch p5js-visualization trigonometric-calculations

sin_cos_orbit's Introduction

sin_cos_orbit

Simple Illustration of Sin and Cos (credit Pythagoras et al)

Thanks to Amed Kino for his addition.

// Sin and Cosine - An illustration of their path

var orbitX = 400;
var orbitY = 400;
var orbitRadius = 200;
var angle = 0;
var speed = 0.02;

function setup() {
 createCanvas(800, 800);

}

function draw() {
 background(200);
 
 text("An illustration of Sin and Cos",20,50)
 
 fill(255);
 ellipse(400,400,400)

 var x = orbitX + orbitRadius * cos(angle);
 var y = orbitY + orbitRadius * sin(angle);
 
 //ellipse(orbitX, orbitY, 50, 50);
 ellipse(x, y, 1, 1);
 angle -= speed;

 //triangle
 fill(255);

 line(400,400,x,y); //hypoteneuse
 line(x,y,x,400); //opposite
 line(400,400,x,400); //adjacent
 
 ellipse(150,y,100,100)
 ellipse(x,150,100,100)

 
 // Show Sin, Cos, Tan
 fill(0);
 text("Sin: "+ 
 round(sin(-angle),2),120,y);
 
 text("Cos: "+ 
 round(cos(-angle),2),x-30,150);

}

sin_cos_orbit's People

Contributors

amed avatar benjaminfox1 avatar

Watchers

 avatar

Forkers

amed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.