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 — random2D() / Reference

Reference+
Documentation→Reference→Math→PVector

Name

random2D()

Class

PVector

Description

Returns a new 2D unit vector with a random direction. If you pass in this as an argument, it will use the PApplet's random number generator.

Examples

  • PVector v;
    
    void setup() {
      v = PVector.random2D();
      println(v);
      // May print something like:
      // [ -0.75006354, -0.6613658, 0.0 ] or 
      // [ 0.13742635, 0.990512, 0.0 ] or 
      // [ -0.9456181, -0.32527903, 0.0 ]
    }
    

Syntax

  • .random2D()
  • .random2D(parent)
  • .random2D(target)
  • .random2D(target, parent)

Parameters

  • parent(PApplet)current PApplet instance
  • target(PVector)the target vector (if null, a new vector will be created)

Return

  • PVector

Related

  • PVector::random3D()
Creative Commons License

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

You are visitor 01402503 — 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.