GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Processing
  • Download
  • Reference
  • Environment
  • Libraries
  • Tools
  • Wiki
  • Tutorials
  • Examples
  • Books
  • Forum
  • Overview
  • People
  • Privacy

This view

  • Original page
  • New address

GeezerVison is showing processing.org — atan2() / Reference

Reference+
Documentation→Reference→Math→Trigonometry

Name

atan2()

Description

Calculates the angle (in radians) from a specified point to the coordinate origin as measured from the positive x-axis. Values are returned as a float in the range from PI to -PI. The atan2() function is most often used for orienting geometry to the position of the cursor. Note: The y-coordinate of the point is the first parameter and the x-coordinate is the second due the structure of calculating the tangent.

Examples

  • void draw() {
      background(204);
      translate(width/2, height/2);
      float a = atan2(mouseY-height/2, mouseX-width/2);
      rotate(a);
      rect(-30, -5, 60, 10);
    }
    

Syntax

  • atan2(y, x)

Parameters

  • y(float)y-coordinate of the point
  • x(float)x-coordinate of the point

Return

  • float

Related

  • tan()
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.