Vocabulary/rdot

From J Wiki
Jump to navigation Jump to search

>> <<   Down to: Dyad   Back to: Vocabulary Thru to: Dictionary

r. y Angle

Rank 0 -- operates on individual atoms of y, producing a result of the same shape -- WHY IS THIS IMPORTANT?


The angle y (in radians), expressed as a unit vector in the complex plane

i.e. a pair of coordinates combined into a complex number

   ] a=: 0.25p1   NB. 45-degree angle in radians
0.785398

   r. a           NB. coordinates are equal
0.707107j0.707107
   plot 0, (r. a)
Plot1.jpg

Common uses

1. Work with 2-D coordinate geometry.

2. Plot a semicircle

Note that the plot package automatically treats complex numbers as (x,y)-coordinates.

   load 'plot'
   a=: 0.01p1          NB. an angle of one hundredth of a radian
   plot r. a * i.100   NB. increase angle in 100 steps of +a
Plot2.jpg

Related Primitives

Real/Imag (+. y), Signum (Unit Circle) (* y), Length/Angle (*. y), Magnitude (| y), Imaginary * Complex (j.), Circle Functions (x o. y)


x r. y Polar

Rank 0 0 -- operates on individual atoms of x and y, producing a result of the same shape -- WHY IS THIS IMPORTANT?


Like monadic (r.), but with a scaling factor x

   assert (x r. a) -: x*(r.a)   NB. true for any 2 numbers: x, a

Common uses

Convert polar coordinates (distance x, angle y) into Cartesian coordinates, expressed as a complex number.


Related Primitives

Real/Imag (+. y), Signum (Unit Circle) (* y), Length/Angle (*. y), Magnitude (| y), Imaginary * Complex (j.), Circle Functions (x o. y)