001/* 002 * Renderer Models. The MIT License. 003 * Copyright (c) 2022 rlkraft@pnw.edu 004 * See LICENSE for details. 005*/ 006 007package renderer.models_L; 008 009import renderer.scene.*; 010import renderer.scene.primitives.*; 011 012import java.awt.Color; 013 014/** 015 Create a positive x, y, and z axis in 3-dimensional space. 016*/ 017public class Axes3D extends Model 018{ 019 /** 020 Create a positive x, y, and z axis 021 with one unit length for each axis. 022 The default {@link Color} is white. 023 */ 024 public Axes3D( ) 025 { 026 this(1.0, 1.0, 1.0); 027 } 028 029 030 /** 031 Create a positive x, y, and z axis 032 with the given length for each axis. 033 The default {@link Color} is white. 034 035 @param xMax length of the x-axis 036 @param yMax length of the y-axis 037 @param zMax length of the z-axis 038 */ 039 public Axes3D(final double xMax, final double yMax, final double zMax) 040 { 041 this(xMax, yMax, zMax, Color.white); 042 } 043 044 045 /** 046 Create a positive x, y, and z axis 047 with the given length for each axis. 048 Use the given {@link Color} for all three axes. 049 050 @param xMax length of the x-axis 051 @param yMax length of the y-axis 052 @param zMax length of the z-axis 053 @param c {@link Color} for all three axes 054 */ 055 public Axes3D(final double xMax, final double yMax, final double zMax, 056 final Color c) 057 { 058 this(xMax, yMax, zMax, c, c, c); 059 } 060 061 062 /** 063 Create a positive x, y, and z axis 064 with the given length for each axis. 065 Use the given {@link Color} for each axis. 066 067 @param xMax length of the x-axis 068 @param yMax length of the y-axis 069 @param zMax length of the z-axis 070 @param cX {@link Color} for the x-axis 071 @param cY {@link Color} for the y-axis 072 @param cZ {@link Color} for the z-axis 073 */ 074 public Axes3D(final double xMax, final double yMax, final double zMax, 075 final Color cX, final Color cY, final Color cZ) 076 { 077 this(0.0, xMax, 0.0, yMax, 0.0, zMax, cX, cY, cZ); 078 } 079 080 081 /** 082 Create an x, y, and z axis with the 083 given endpoints for each axis. 084 The default {@link Color} is black. 085 086 @param xMin left endpoint of the x-axis 087 @param xMax right endpoint of the x-axis 088 @param yMin bottom endpoint of the y-axis 089 @param yMax top endpoint of the y-axis 090 @param zMin back endpoint of the z-axis 091 @param zMax front endpoint of the z-axis 092 */ 093 public Axes3D(final double xMin, final double xMax, 094 final double yMin, final double yMax, 095 final double zMin, final double zMax) 096 { 097 this(xMin, xMax, yMin, yMax, zMin, zMax, Color.black); 098 } 099 100 101 /** 102 Create an x, y, and z axis with the 103 given endpoints for each axis. 104 Use the given {@link Color} for all three axes. 105 106 @param xMin left endpoint of the x-axis 107 @param xMax right endpoint of the x-axis 108 @param yMin bottom endpoint of the y-axis 109 @param yMax top endpoint of the y-axis 110 @param zMin back endpoint of the z-axis 111 @param zMax front endpoint of the z-axis 112 @param c {@link Color} for all three axes 113 */ 114 public Axes3D(final double xMin, final double xMax, 115 final double yMin, final double yMax, 116 final double zMin, final double zMax, 117 final Color c) 118 { 119 this(xMin, xMax, yMin, yMax, zMin, zMax, c, c, c); 120 } 121 122 123 /** 124 Create an x, y, and z axis with the 125 given endpoints for each axis. 126 Use the given {@link Color} for each axis. 127 128 @param xMin left endpoint of the x-axis 129 @param xMax right endpoint of the x-axis 130 @param yMin bottom endpoint of the y-axis 131 @param yMax top endpoint of the y-axis 132 @param zMin back endpoint of the z-axis 133 @param zMax front endpoint of the z-axis 134 @param cX {@link Color} for the x-axis 135 @param cY {@link Color} for the y-axis 136 @param cZ {@link Color} for the z-axis 137 */ 138 public Axes3D(final double xMin, final double xMax, 139 final double yMin, final double yMax, 140 final double zMin, final double zMax, 141 final Color cX, final Color cY, final Color cZ) 142 { 143 super("Axes 3D"); 144 145 addVertex(new Vertex(xMin, 0, 0), 146 new Vertex(xMax, 0, 0), 147 new Vertex( 0, yMin, 0), 148 new Vertex( 0, yMax, 0), 149 new Vertex( 0, 0, zMin), 150 new Vertex( 0, 0, zMax)); 151 152 addColor(cX, cY, cZ); 153 154 addPrimitive(new LineSegment(0, 1, 0), // use color cX 155 new LineSegment(2, 3, 1), // use color cY 156 new LineSegment(4, 5, 2)); // use color cZ 157 } 158}//Axes3D