Function Repository Resource:

Rhombus

Source Notebook

Produce a rhombus for use in graphics

Contributed by: Sander Huisman

ResourceFunction["Rhombus"][]

returns an axis-aligned golden rhombus centered around the origin with side length 1.

ResourceFunction["Rhombus"][{x,y}]

returns an axis-aligned golden rhombus centered around {x,y} with side length 1.

ResourceFunction["Rhombus"][{x,y},a]

returns an axis-aligned golden rhombus centered around {x,y} with side length a.

ResourceFunction["Rhombus"][{x,y},a,θ]

returns an axis-aligned rhombus centered around {x,y} with side length a and half-angle θ.

ResourceFunction["Rhombus"][{x,y},a,θ,ϕ]

returns a rhombus centered around {x,y} with side length a and half-angle θ and tilted at an angle ϕ.

ResourceFunction["Rhombus"][{x,y},{p,q}]

returns an axis-aligned rhombus centered around {x,y} with semi-axes lengths p and q.

ResourceFunction["Rhombus"][{x,y},{p,q},ϕ]

returns a rhombus centered around {x,y} with semi-axis lengths p and q and tilted at an angle ϕ.

Details and Options

A rhombus is a quadrilateral whose four sides all have the same length.
A rhombus is sometimes called a diamond, a lozenge, or a calisson.
The parameters x, y, a, p, q, θ and ϕ are defined as follows:

Examples

Basic Examples (2) 

Generate a golden rhombus with unit side lengths centered around the origin:

In[1]:=
ResourceFunction["Rhombus"][]
Out[1]=

Generate a lozenge with unit side lengths centered around the origin:

In[2]:=
Graphics[ResourceFunction["Rhombus"][{0, 0}, 1, 22.5 Degree], ImageSize -> 100]
Out[2]=

Scope (3) 

Create a rhombus defined by its axis lengths:

In[3]:=
Graphics[ResourceFunction["Rhombus"][{0, 0}, {2, 3}], ImageSize -> 100]
Out[3]=

Define a rhombus by a side length and an angle:

In[4]:=
Graphics[ResourceFunction["Rhombus"][{0, 0}, 1, 15 Degree], ImageSize -> 100]
Out[4]=

Create a rhombus defined by its axis lengths and rotate it 35° counter-clockwise:

In[5]:=
Graphics[ResourceFunction["Rhombus"][{0, 0}, {2, 1}, 35 Degree], ImageSize -> 100]
Out[5]=

Applications (1) 

Use rhombuses as error bars:

In[6]:=
data = {{Around[3, 0.2], Around[2, 0.2]}, {Around[4, 0.12], Around[1, 0.25]}, {Around[3.5, 0.1], Around[1.7, 0.4]}, {Around[4.5, 0.6], Around[2.5, 0.25]}};
Graphics[
 Cases[data, {Around[x_, dx_], Around[y_, dy_]} :> ResourceFunction["Rhombus"][{x, y}, {dx, dy}]], Frame -> True]
Out[7]=

Possible Issues (1) 

With an angle of 0 or 180 degrees, the polygon will have no area (a degenerate polygon):

In[8]:=
ResourceFunction["Rhombus"][{10, 10}, 1, #] & /@ {0 Degree, 180 Degree}
Out[8]=

Neat Examples (1) 

Create a visually appealing collection of rhombuses:

In[9]:=
Graphics[{FaceForm[], EdgeForm[Black], ResourceFunction["Rhombus"][{0, 0}, #^3, 30 Degree, #/10 - 2] & /@ Range[20, 1, -1]}, ImageSize -> 500]
Out[9]=

Publisher

SHuisman

Version History

  • 1.0.0 – 26 December 2019

Related Resources

License Information