Skip to content
jasondavies edited this page Jul 25, 2012 · 7 revisions

WikiAPI ReferenceCoreMath

Pseudorandom Number Generation

# d3.random.normal([mean, [deviation]])

Returns a function for generating random numbers with a normal (Gaussian) distribution. The expected value of the generated pseudorandom numbers is mean, with the given standard deviation. If deviation is not specified, it defaults to 1.0; if mean is not specified, it defaults to 0.0.

2D Transforms

# d3.transform(string)

Parses the given 2D affine transform string, as defined by SVG's transform attribute. The transform is then decomposed to a standard representation of translate, rotate, x-skew and scale. This behavior is standardized by CSS: see matrix decomposition for animation.

# transform.rotate

Returns the rotation angle θ of this transform, in degrees.

# transform.translate

Returns the [dx, dy] translation of this transform, as a two-element array in local coordinates (typically pixels).

# transform.skew

Returns the x-skew φ of this transform, in degrees.

# transform.scale

Returns the [kx, ky] scale of this transform, as a two-element array.

# transform.toString

Returns a string representation of this transform, in the form "translate(dx,dy)rotate(θ)skewX(φ)scale(kx,ky)".

Clone this wiki locally