001/** 002 Returns a <code>Vector</code> instance with the specified components. When units are 003 not stated explicitly, they are assumed to be meters. The versions showing the array 004 input actually take a variable length argument list (vararg), so you can enter 005 <code>newVector(x, y, z, w)</code>, etc. 006 007 @method Vector newVector(double... axesVararg) 008 @method Vector newVector(Unit unit, double... axesVararg) 009 @method Vector newVector(GeomPoint origin, double... axesVararg) 010 @method Vector newVector(GeomPoint origin, Unit unit, double... axesVararg) 011 @method Vector newVector(double x, Unit unit) 012 @method Vector newVector(double x, double y, Unit unit) 013 @method Vector newVector(double x, double y, double z, Unit unit) 014 @method Vector newVector(double x, double y, double z, double w, Unit unit) 015 @method Vector newVector(Parameter... axesVararg) 016 @method Vector newVector(GeomPoint origin, Parameter... axesVararg) 017 */ 018package geomss.app.GeomSSCommands.creators; 019 020import bsh.*; 021import geomss.geom.GeomPoint; 022import geomss.geom.Vector; 023import jahuwaldt.js.param.Parameter; 024import javax.measure.unit.Unit; 025 026public class newVector { 027 028 public static String usage() { 029 return "usage: newVector(x,y,unit);, or newVector(origin, x,y,z);"; 030 } 031 032 /** 033 * Implement newVector(double... axesVararg) command. 034 */ 035 public static Vector invoke(Interpreter env, CallStack callstack, 036 double... axesVararg) { 037 return Vector.valueOf(axesVararg); 038 } 039 040 /** 041 * Implement newVector(Unit unit, double... axesVararg) command. 042 */ 043 public static Vector invoke(Interpreter env, CallStack callstack, 044 Unit unit, double... axesVararg) { 045 return Vector.valueOf(unit, axesVararg); 046 } 047 048 /** 049 * Implement newVector(GeomPoint origin, double... axesVararg) command. 050 */ 051 public static Vector invoke(Interpreter env, CallStack callstack, 052 GeomPoint origin, double... axesVararg) { 053 Vector u = Vector.valueOf(axesVararg); 054 u.setOrigin(origin.immutable()); 055 return u; 056 } 057 058 /** 059 * Implement newVector(GeomPoint origin, Unit unit, double... axesVararg) command. 060 */ 061 public static Vector invoke(Interpreter env, CallStack callstack, 062 GeomPoint origin, Unit unit, double... axesVararg) { 063 Vector u = Vector.valueOf(unit, axesVararg); 064 u.setOrigin(origin.immutable()); 065 return u; 066 } 067 068 /** 069 * Implement newVector(double x, Unit unit) command. 070 */ 071 public static Vector invoke(Interpreter env, CallStack callstack, 072 double x, Unit unit) { 073 return Vector.valueOf(unit, x); 074 } 075 076 /** 077 * Implement newVector(double x, double y, Unit unit) command. 078 */ 079 public static Vector invoke(Interpreter env, CallStack callstack, 080 double x, double y, Unit unit) { 081 return Vector.valueOf(unit, x, y); 082 } 083 084 /** 085 * Implement newVector(double x, double y, double z, Unit unit) command. 086 */ 087 public static Vector invoke(Interpreter env, CallStack callstack, 088 double x, double y, double z, Unit unit) { 089 return Vector.valueOf(unit, x, y, z); 090 } 091 092 /** 093 * Implement newVector(double x, double y, double z, double w, Unit unit) command. 094 */ 095 public static Vector invoke(Interpreter env, CallStack callstack, 096 double x, double y, double z, double w, Unit unit) { 097 return Vector.valueOf(unit, x, y, z, w); 098 } 099 100 /** 101 * Implement newVector(Parameter... axesVararg) command. 102 */ 103 public static Vector invoke(Interpreter env, CallStack callstack, 104 Parameter... axesVararg) { 105 return Vector.valueOf(axesVararg); 106 } 107 108 /** 109 * Implement newVector(GeomPoint origin, Parameter... axesVararg) command. 110 */ 111 public static Vector invoke(Interpreter env, CallStack callstack, 112 GeomPoint origin, Parameter... axesVararg) { 113 Vector u = Vector.valueOf(axesVararg); 114 u.setOrigin(origin.immutable()); 115 return u; 116 } 117 118}