Function Repository Resource:

Gnomon

Source Notebook

Produce a gnomon to be used in 3D graphics to indicate the origin and the principal axes

Contributed by: Sander Huisman

ResourceFunction["Gnomon"][]

produces a gnomon at {0,0,0} with unit length.

ResourceFunction["Gnomon"][p]

produces a gnomon with the origin at point p.

ResourceFunction["Gnomon"][p,axes]

produces a gnomon with the origin at point p, and the principal axes axes.

Details and Options

A gnomon is commonly placed in 3D graphics or in CAD software like Solidworks, Blender, Autodesk, etc. to indicate the location of the origin and the direction of the principal axes.
The following options can be given:
"ArrowExtent"Scaled[0.3]extent of the arrows
"ArrowThickness"Scaled[2]size of the arrows
"Colors"{Red,Green,Blue}colors of the axes
"AxesLength"1length of the axes
Lighting"Neutral"Lighting option that specifies what light should be used to illuminate the gnomon
"OriginColor"GrayLevel[0.8]color of the origin
"OriginSize"Scaled[0.12]size of the origin
"AxesThickness"Scaled[0.06]thickness of the axes
The option "ArrowExtent" should be a Scaled quantity giving the relative size of the arrow with respect to the shortest axis.
The option "ArrowThickness" should be a number or a Scaled quantity giving the thickness of the arrow. For a Scaled quantity this is then multiplied with the "Thickness" option.
The option "Colors" can be a single color, or a list of three colors, specifying the color for each axis.
The option "AxesLength" can be a single number, or a list of three numbers, specifying the length of each axis separately.
The option "OriginSize" can be a single number or a Scaled quantity. For a Scaled quantity this is then scaled with respect to the longest axis.
The option "AxesThickness" can be a single number or a Scaled quantity. For a Scaled quantity this is then scaled with respect to the longest axis.

Examples

Basic Examples (1) 

Create a basic gnomon:

In[1]:=
Graphics3D[ResourceFunction["Gnomon"][]]
Out[1]=

Scope (2) 

Position the gnomon at {1,2,3}:

In[2]:=
Graphics3D[ResourceFunction["Gnomon"][{1, 2, 3}], Axes -> True]
Out[2]=

Rotate the gnomon:

In[3]:=
Graphics3D[
 ResourceFunction["Gnomon"][{0, 0, 0}, RotationMatrix[-30 Degree, {1, -1, 0}]], Axes -> True]
Out[3]=

Options (16) 

ArrowExtent (1) 

Change the extent of the arrows:

In[4]:=
Graphics3D[ResourceFunction["Gnomon"]["ArrowExtent" -> Scaled[0.6]], Axes -> True]
Out[4]=

ArrowThickness (3) 

Create wider arrow heads:

In[5]:=
Graphics3D[ResourceFunction["Gnomon"]["ArrowThickness" -> Scaled[3]], Axes -> True]
Out[5]=

Make the arrow a different size for each axes:

In[6]:=
Graphics3D[
 ResourceFunction["Gnomon"][
  "ArrowThickness" -> {Scaled[1.5], Scaled[2.5], Scaled[3.5]}], Axes -> True]
Out[6]=

For differently-sized axes, the shortest axis is taken as reference:

In[7]:=
Graphics3D[
 ResourceFunction["Gnomon"]["AxesLength" -> {1.5, 2, 2.5}, "ArrowExtent" -> Scaled[0.5]], Axes -> True]
Out[7]=

Colors (2) 

Provide custom colors for the axes:

In[8]:=
Graphics3D[
 ResourceFunction["Gnomon"][
  "Colors" -> {RGBColor[0.368417, 0.506779, 0.709798], RGBColor[
    0.880722, 0.611041, 0.142051], RGBColor[
    0.560181, 0.691569, 0.194885]}]]
Out[8]=

A specification of a single color colors all axes that color:

In[9]:=
Graphics3D[ResourceFunction["Gnomon"]["Colors" -> GrayLevel[0.4]]]
Out[9]=

Length (2) 

Make all axes a length of 4:

In[10]:=
Graphics3D[ResourceFunction["Gnomon"]["AxesLength" -> 4], Axes -> True]
Out[10]=

Give the axes different lengths:

In[11]:=
Graphics3D[ResourceFunction["Gnomon"]["AxesLength" -> {1.5, 2, 2.5}], Axes -> True]
Out[11]=

Lighting (2) 

Use the standard 4 colored lights:

In[12]:=
Graphics3D[ResourceFunction["Gnomon"][Lighting -> Automatic]]
Out[12]=

Use 3-point lighting:

In[13]:=
Graphics3D[ResourceFunction["Gnomon"][Lighting -> "ThreePoint"]]
Out[13]=

OriginColor (2) 

Change the color of the origin to black:

In[14]:=
Graphics3D[ResourceFunction["Gnomon"]["OriginColor" -> Black]]
Out[14]=

Make it semi-transparent:

In[15]:=
Graphics3D[
 ResourceFunction["Gnomon"][
  "OriginColor" -> Directive[Black, Opacity[0.5]]]]
Out[15]=

OriginSize (2) 

Specify a size:

In[16]:=
Graphics3D[ResourceFunction["Gnomon"]["OriginSize" -> 0.25]]
Out[16]=

Specify a relative size:

In[17]:=
Graphics3D[ResourceFunction["Gnomon"]["OriginSize" -> Scaled[0.1]]]
Out[17]=

Thickness (2) 

Specify a size:

In[18]:=
Graphics3D[ResourceFunction["Gnomon"]["AxesThickness" -> 0.03]]
Out[18]=

Specify a relative size:

In[19]:=
Graphics3D[
 ResourceFunction["Gnomon"]["AxesThickness" -> Scaled[0.08]]]
Out[19]=

Possible Issues (1) 

By default tubes and spheres are rendered with relatively few points, this can be modified as an option in Graphics3D:

In[20]:=
{Graphics3D[
   ResourceFunction["Gnomon"]["AxesThickness" -> Scaled[0.08]], ImageSize -> 250],
  Graphics3D[
   ResourceFunction["Gnomon"]["AxesThickness" -> Scaled[0.08]], ImageSize -> 250, Method -> {"SpherePoints" -> 50, "TubePoints" -> {50, 2}}]} // Row
Out[20]=

Neat Examples (2) 

Add a gnomon to a 3D graphic with custom colors and size:

In[21]:=
Show[{
  ContourPlot3D[
   x^3 + y^2 - z^2 == 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, PlotRangePadding -> 0.35, Boxed -> False, Axes -> False],
  Graphics3D[
   ResourceFunction["Gnomon"][{-2.2, -2.2, -2.2}, "Colors" -> {Darker[Cyan], Purple, Orange}, "AxesLength" -> 1.25, "OriginColor" -> GrayLevel[0.7], "ArrowThickness" -> Scaled[2.25]]]
  }]

The principal axes don't have to be mutually perpendicular:

In[22]:=
Show[{
  ParametricPlot3D[{1, 1, 1} + u {1, 1, 0} + v {0, 1, 1/2}, {u, -1, 0}, {v, -1, 0}, Mesh -> 5, BoundaryStyle -> Black, PlotRangePadding -> 0.25, AspectRatio -> Automatic],
  Graphics3D[
   ResourceFunction[
    "Gnomon"][{0, -1, 1/2} + 0.25 {1/2, -(1/2), 1}, {{1, 1, 0}, {0, 1, 1/2}, {0, 0, 1}}, "AxesLength" -> 0.5]]
  }]
Out[22]=

Publisher

SHuisman

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 15 May 2024

Related Resources

License Information