1 package org.djunits.value.vdouble.vector; 2 3 import java.util.List; 4 import java.util.Map; 5 6 import org.djunits.unit.AngleUnit; 7 import org.djunits.unit.DirectionUnit; 8 import org.djunits.unit.scale.IdentityScale; 9 import org.djunits.value.storage.StorageType; 10 import org.djunits.value.vdouble.scalar.Angle; 11 import org.djunits.value.vdouble.scalar.Direction; 12 import org.djunits.value.vdouble.vector.base.DoubleVectorRelWithAbs; 13 import org.djunits.value.vdouble.vector.data.DoubleVectorData; 14 15 import jakarta.annotation.Generated; 16 17 /** 18 * Double AngleVector, a vector of values with a AngleUnit. 19 * <p> 20 * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 21 * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>. 22 * </p> 23 * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a> 24 * @author <a href="https://www.tudelft.nl/staff/p.knoppers/">Peter Knoppers</a> 25 */ 26 @Generated(value = "org.djunits.generator.GenerateDJUNIT", date = "2023-07-23T14:06:38.224104100Z") 27 public class AngleVector 28 extends DoubleVectorRelWithAbs<DirectionUnit, Direction, DirectionVector, AngleUnit, Angle, AngleVector> 29 { 30 /** */ 31 private static final long serialVersionUID = 20190905L; 32 33 /** 34 * Construct an AngleVector from an internal data object. 35 * @param data DoubleVectorData; the internal data object for the vector 36 * @param displayUnit AngleUnit; the display unit of the vector data 37 */ 38 public AngleVector(final DoubleVectorData data, final AngleUnit displayUnit) 39 { 40 super(data, displayUnit); 41 } 42 43 /* CONSTRUCTORS WITH double[] */ 44 45 /** 46 * Construct an AngleVector from a double[] object. The double values are expressed in the displayUnit, and will be printed 47 * using the displayUnit. 48 * @param data double[]; the data for the vector, expressed in the displayUnit 49 * @param displayUnit AngleUnit; the unit of the values in the data array, and display unit when printing 50 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 51 */ 52 public AngleVector(final double[] data, final AngleUnit displayUnit, final StorageType storageType) 53 { 54 this(DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType), displayUnit); 55 } 56 57 /** 58 * Construct an AngleVector from a double[] object. The double values are expressed in the displayUnit. Assume that the 59 * StorageType is DENSE since we offer the data as an array. 60 * @param data double[]; the data for the vector 61 * @param displayUnit AngleUnit; the unit of the values in the data array, and display unit when printing 62 */ 63 public AngleVector(final double[] data, final AngleUnit displayUnit) 64 { 65 this(data, displayUnit, StorageType.DENSE); 66 } 67 68 /** 69 * Construct an AngleVector from a double[] object with SI-unit values. 70 * @param data double[]; the data for the vector, in SI units 71 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 72 */ 73 public AngleVector(final double[] data, final StorageType storageType) 74 { 75 this(data, AngleUnit.SI, storageType); 76 } 77 78 /** 79 * Construct an AngleVector from a double[] object with SI-unit values. Assume that the StorageType is DENSE since we offer 80 * the data as an array. 81 * @param data double[]; the data for the vector, in SI units 82 */ 83 public AngleVector(final double[] data) 84 { 85 this(data, StorageType.DENSE); 86 } 87 88 /* CONSTRUCTORS WITH Angle[] */ 89 90 /** 91 * Construct an AngleVector from an array of Angle objects. The Angle values are each expressed in their own unit, but will 92 * be internally stored as SI values, all expressed in the displayUnit when printing. 93 * @param data Angle[]; the data for the vector 94 * @param displayUnit AngleUnit; the display unit of the values when printing 95 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 96 */ 97 public AngleVector(final Angle[] data, final AngleUnit displayUnit, final StorageType storageType) 98 { 99 this(DoubleVectorData.instantiate(data, storageType), displayUnit); 100 } 101 102 /** 103 * Construct an AngleVector from an array of Angle objects. The Angle values are each expressed in their own unit, but will 104 * be internally stored as SI values, all expressed in the displayUnit when printing. Assume that the StorageType is DENSE 105 * since we offer the data as an array. 106 * @param data Angle[]; the data for the vector 107 * @param displayUnit AngleUnit; the display unit of the values when printing 108 */ 109 public AngleVector(final Angle[] data, final AngleUnit displayUnit) 110 { 111 this(data, displayUnit, StorageType.DENSE); 112 } 113 114 /** 115 * Construct an AngleVector from an array of Angle objects. The Angle values are each expressed in their own unit, but will 116 * be internally stored as SI values, and expressed using SI units when printing. since we offer the data as an array. 117 * @param data Angle[]; the data for the vector 118 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 119 */ 120 public AngleVector(final Angle[] data, final StorageType storageType) 121 { 122 this(data, AngleUnit.SI, storageType); 123 } 124 125 /** 126 * Construct an AngleVector from an array of Angle objects. The Angle values are each expressed in their own unit, but will 127 * be internally stored as SI values, and expressed using SI units when printing. Assume that the StorageType is DENSE since 128 * we offer the data as an array. 129 * @param data Angle[]; the data for the vector 130 */ 131 public AngleVector(final Angle[] data) 132 { 133 this(data, StorageType.DENSE); 134 } 135 136 /* CONSTRUCTORS WITH List<Double> or List<Angle> */ 137 138 /** 139 * Construct an AngleVector from a list of Number objects or a list of Angle objects. Note that the displayUnit has a 140 * different meaning depending on whether the list contains Number objects (e.g., Double objects) or Angle objects. In case 141 * the list contains Number objects, the displayUnit indicates the unit in which the values in the list are expressed, as 142 * well as the unit in which they will be printed. In case the list contains Angle objects, each Angle has its own unit, and 143 * the displayUnit is just used for printing. The values but will always be internally stored as SI values or base values, 144 * and expressed using the display unit or base unit when printing. 145 * @param data List<Double> or List<Angle>; the data for the vector 146 * @param displayUnit AngleUnit; the display unit of the vector data, and the unit of the data points when the data is 147 * expressed as List<Double> or List<Number> in general 148 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 149 */ 150 public AngleVector(final List<? extends Number> data, final AngleUnit displayUnit, final StorageType storageType) 151 { 152 this(data.size() == 0 ? DoubleVectorData.instantiate(new double[] {}, IdentityScale.SCALE, storageType) 153 : data.get(0) instanceof Angle ? DoubleVectorData.instantiate(data, IdentityScale.SCALE, storageType) 154 : DoubleVectorData.instantiate(data, displayUnit.getScale(), storageType), 155 displayUnit); 156 } 157 158 /** 159 * Construct an AngleVector from a list of Number objects or a list of Angle objects. Note that the displayUnit has a 160 * different meaning depending on whether the list contains Number objects (e.g., Double objects) or Angle objects. In case 161 * the list contains Number objects, the displayUnit indicates the unit in which the values in the list are expressed, as 162 * well as the unit in which they will be printed. In case the list contains Angle objects, each Angle has its own unit, and 163 * the displayUnit is just used for printing. The values but will always be internally stored as SI values or base values, 164 * and expressed using the display unit or base unit when printing. Assume the storage type is DENSE since we offer the data 165 * as a List. 166 * @param data List<Double> or List<Angle>; the data for the vector 167 * @param displayUnit AngleUnit; the display unit of the vector data, and the unit of the data points when the data is 168 * expressed as List<Double> or List<Number> in general 169 */ 170 public AngleVector(final List<? extends Number> data, final AngleUnit displayUnit) 171 { 172 this(data, displayUnit, StorageType.DENSE); 173 } 174 175 /** 176 * Construct an AngleVector from a list of Number objects or a list of Angle objects. When data contains numbers such as 177 * Double, assume that they are expressed using SI units. When the data consists of Angle objects, they each have their own 178 * unit, but will be printed using SI units or base units. The values but will always be internally stored as SI values or 179 * base values, and expressed using the display unit or base unit when printing. 180 * @param data List<Double> or List<Angle>; the data for the vector 181 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 182 */ 183 public AngleVector(final List<? extends Number> data, final StorageType storageType) 184 { 185 this(data, AngleUnit.SI, storageType); 186 } 187 188 /** 189 * Construct an AngleVector from a list of Number objects or a list of Angle objects. When data contains numbers such as 190 * Double, assume that they are expressed using SI units. When the data consists of Angle objects, they each have their own 191 * unit, but will be printed using SI units or base units. The values but will always be internally stored as SI values or 192 * base values, and expressed using the display unit or base unit when printing. Assume the storage type is DENSE since we 193 * offer the data as a List. 194 * @param data List<Double> or List<Angle>; the data for the vector 195 */ 196 public AngleVector(final List<? extends Number> data) 197 { 198 this(data, StorageType.DENSE); 199 } 200 201 /* CONSTRUCTORS WITH Map<Integer, Double> or Map<Integer, Angle> */ 202 203 /** 204 * Construct an AngleVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to of 205 * Angle objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the size of the 206 * vector, since the largest index does not have to be part of the map. Note that the displayUnit has a different meaning 207 * depending on whether the map contains Number objects (e.g., Double objects) or Angle objects. In case the map contains 208 * Number objects, the displayUnit indicates the unit in which the values in the map are expressed, as well as the unit in 209 * which they will be printed. In case the map contains Angle objects, each Angle has its own unit, and the displayUnit is 210 * just used for printing. The values but will always be internally stored as SI values or base values, and expressed using 211 * the display unit or base unit when printing. 212 * @param data Map<Integer, Double> or Map<Integer, Angle>; the data for the vector 213 * @param size int; the size off the vector, i.e., the highest index 214 * @param displayUnit AngleUnit; the display unit of the vector data, and the unit of the data points when the data is 215 * expressed as List<Double> or List<Number> in general 216 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 217 */ 218 public AngleVector(final Map<Integer, ? extends Number> data, final int size, final AngleUnit displayUnit, 219 final StorageType storageType) 220 { 221 this(data.size() == 0 ? DoubleVectorData.instantiate(data, size, IdentityScale.SCALE, storageType) 222 : data.values().iterator().next() instanceof Angle 223 ? DoubleVectorData.instantiate(data, size, IdentityScale.SCALE, storageType) 224 : DoubleVectorData.instantiate(data, size, displayUnit.getScale(), storageType), 225 displayUnit); 226 } 227 228 /** 229 * Construct an AngleVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to of 230 * Angle objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the size of the 231 * vector, since the largest index does not have to be part of the map. Note that the displayUnit has a different meaning 232 * depending on whether the map contains Number objects (e.g., Double objects) or Angle objects. In case the map contains 233 * Number objects, the displayUnit indicates the unit in which the values in the map are expressed, as well as the unit in 234 * which they will be printed. In case the map contains Angle objects, each Angle has its own unit, and the displayUnit is 235 * just used for printing. The values but will always be internally stored as SI values or base values, and expressed using 236 * the display unit or base unit when printing. Assume the storage type is SPARSE since we offer the data as a Map. 237 * @param data Map<Integer, Double> or Map<Integer, Angle>; the data for the vector 238 * @param size int; the size off the vector, i.e., the highest index 239 * @param displayUnit AngleUnit; the display unit of the vector data, and the unit of the data points when the data is 240 * expressed as List<Double> or List<Number> in general 241 */ 242 public AngleVector(final Map<Integer, ? extends Number> data, final int size, final AngleUnit displayUnit) 243 { 244 this(data, size, displayUnit, StorageType.SPARSE); 245 } 246 247 /** 248 * Construct an AngleVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to of 249 * Angle objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the size of the 250 * vector, since the largest index does not have to be part of the map. When data contains numbers such as Double, assume 251 * that they are expressed using SI units. When the data consists of Angle objects, they each have their own unit, but will 252 * be printed using SI units or base units. The values but will always be internally stored as SI values or base values, and 253 * expressed using the display unit or base unit when printing. 254 * @param data Map<Integer, Double> or Map<Integer, Angle>; the data for the vector 255 * @param size int; the size off the vector, i.e., the highest index 256 * @param storageType StorageType; the StorageType (SPARSE or DENSE) to use for constructing the Vector 257 */ 258 public AngleVector(final Map<Integer, ? extends Number> data, final int size, final StorageType storageType) 259 { 260 this(data, size, AngleUnit.SI, storageType); 261 } 262 263 /** 264 * Construct an AngleVector from a (sparse) map of index values to Number objects or a (sparse) map of index values to of 265 * Angle objects. Using index values is particularly useful for sparse vectors. The size parameter indicates the size of the 266 * vector, since the largest index does not have to be part of the map. When data contains numbers such as Double, assume 267 * that they are expressed using SI units. When the data consists of Angle objects, they each have their own unit, but will 268 * be printed using SI units or base units. The values but will always be internally stored as SI values or base values, and 269 * expressed using the display unit or base unit when printing. Assume the storage type is SPARSE since we offer the data as 270 * a Map. 271 * @param data Map<Integer, Double> or Map<Integer, Angle>; the data for the vector 272 * @param size int; the size off the vector, i.e., the highest index 273 */ 274 public AngleVector(final Map<Integer, ? extends Number> data, final int size) 275 { 276 this(data, size, StorageType.SPARSE); 277 } 278 279 /* ****************************** Other methods ****************************** */ 280 281 @Override 282 public Class<Angle> getScalarClass() 283 { 284 return Angle.class; 285 } 286 287 @Override 288 public AngleVector instantiateVector(final DoubleVectorData dvd, final AngleUnit displayUnit) 289 { 290 return new AngleVector(dvd, displayUnit); 291 } 292 293 @Override 294 public Angle instantiateScalarSI(final double valueSI, final AngleUnit displayUnit) 295 { 296 Angle result = Angle.instantiateSI(valueSI); 297 result.setDisplayUnit(displayUnit); 298 return result; 299 } 300 301 @Override 302 public DirectionVector instantiateVectorAbs(final DoubleVectorData dvd, final DirectionUnit displayUnit) 303 { 304 return new DirectionVector(dvd, displayUnit); 305 } 306 307 @Override 308 public Direction instantiateScalarAbsSI(final double valueSI, final DirectionUnit displayUnit) 309 { 310 Direction result = Direction.instantiateSI(valueSI); 311 result.setDisplayUnit(displayUnit); 312 return result; 313 } 314 315 }