Professional Documents
Culture Documents
Variables
Las variables se utilizan para almacenar datos. Cada variable tiene su propio tipo. Procesamiento (y su matriz lenguaje Java) tiene varios tipos de "primitivas" que se utiliza con frecuencia utilizada y la base de otros tipos de datos.
// Integer int i=0; int num1 = 100, num2 = -5; // Float (float point number) float a = 0.0; float minimum = 0.00001; float fval = 10f; //'f' at the end specifies to be float even when number looks like an integer // Double (double precision float point number) double value1 = 0.5; double value2 = .1; double value3 = 0.; //'.' specifies to be double double value4 = 1d; //'d' specifies to be double double x = 0., y= -1.414214, z = 2.236; // String (strictly speaking String is not a primitive type but a class, but it's a very fundamental class in Java.) String txt = "word"; //sandwiched by double-quotation String happyMsg = "The result was successful.";
// Naming Convention #1 int i=0; int xnum=100; double x=10.0; double len=20; double dist1=10, dist2=100; // without '.' it can still be double, actually String errMsg="no data found"; // Naming Convention #2 int pointCount=10; double xOffsetDistance=20.0; double angleOfArc=2.5; double sumOfTotalXShift=10.24; String errorMessage="still no data found"; // Naming Convention #3 int intCounter=0; int intTotalYNumber=10; double dblPointSize=5.5; double dblVectorLength=2.2;
La conclusin es que un nombre de variable no debe ser confuso. Muchas personas recomiendan # 2 y # 3 # 3, pero no es muy comn en Java y de procesamiento y las variables del sistema IGEO se nombran en alguna parte entre el # 1 y # 2.
Declaraciones
Una declaracin es una lnea que ya ha visto en los cdigos de ejemplo anterior que termina con punto y coma (;). Falta un punto y coma al final es un error comn en los principiantes. Por favor, no lo olvides. Una declaracin puede abarcar varias lneas.
int xnum = 10, ynum=20, znum=30; double intervalBetweenPlanes = 20.5; int total = xnum + ynum + znum;
Comentarios
Usted puede escribir comentarios en el cdigo con / / como ya hemos visto en los cdigos de ejemplo. / / Comentarios fuera de texto despus de la seal hasta el final de la lnea. Comentada textos no tiene ningn efecto sobre los cdigos. Hay tambin / * ... * / Pares de signos para comentar varias lneas o una parte de la lnea en el medio. Puede anidar / / inside / * ... * / Pero no se pueden anidar / * ... * / Inside / * ... * /.
// comment example 1 int i=-10; // comment example 2 double x=20 /* comment about x */ , y=-10 /* about y*/ , z = 20 /* about z*/ ; /* Multiple-line commenting sentences. Longer description about something about the code below. */ /* This is OK to have // this comment inside this comment. */ /* This is NOT OK to have /* this comment */ inside this comment. This will cause error. */
Es muy recomendable para aadir comentarios a sus cdigos constantemente, ya que hara que el cdigo sea ms fcil para ser ledo no slo por los dems, sino tambin por s mismo tal vez varios das ms tarde, cuando no recuerdo exactamente la intencin de lo que estaba haciendo.
Ejecutar el Sketch
Para ejecutar el dibujo, haga clic en el botn Ejecutar, escriba Control + R o vaya al men "Sketch"> "Ejecutar".
Para desplazarse por las vistas 3D, el uso del ratn y el teclado de la siguiente manera. ROTACIN: Botn izquierdo del mouse con / sin tecla alt. O las teclas de flecha. PAN: el botn central del ratn o el botn de la izquierda + tecla de maysculas. O shift + teclas de flecha. ZOOM: botn derecho del ratn o el botn izquierdo + tecla de control. O Control + teclas de flecha. TOGGLE VISTA: doble click del ratn de la vista. O espacio de claves. ENFOQUE VER en todos los objetos clave: Tipo de f. Guardar archivos: Control + tecla s. SALIR Y CIERRE: Tipo de control + W o q clave.
Deshacer cambios
Modos de sombreado
iGeo dispone de 5 modos diferentes de sombreado. WIREFRAME : Type w key. SHADE: Type s key. TRANSPARENT SHADE: Type t key. SHADE WITHOUT EDGES: Type shift + s key TRANSPARENT SHADE WITHOUT EDGES: Type shift + t key.
size( 480, 360, IG.GL ); new IPoint(0,0,0).clr(255,0,0); // RGB in int new IPoint(20,0,0).clr(0,0.3,0.9); // RGB in float or double new IPoint(20,20,0).hsb(0.5,1.0,0.9); // HSB in float or double
Creacin de lneas
Para crear objetos de lnea, utilice la clase ICurve (una lnea que se ve como un tipo de curva). Ponga x, y, z del punto de inicio y X, Y, Z del punto final en el argumento.
import processing.opengl.*; import igeo.*; size( 480, 360, IG.GL ); new ICurve(0,0,0, 30,30,30); new ICurve(0,-10,0, 30,10,20).clr(0.5,0,0); new ICurve(0,-20,0, 30,-10,10).clr(1.0,0,0); // NOTE: float is put in clr()
new ICurve(0,-30,0, 30,-30,0).clr(1,0,0); // NOTE: int is put in clr() and the range of int in color is 0-255
// degree 1 curve (polyline) double[][] controlPoints2 = {{-60,-30,0}, {-60,-10,0}, {-40,-30,0}, {-40,-10,0}}; new ICurve(controlPoints2, 1).clr(0,1.,1.); // or you can omit the degree argument for polyline double[][] controlPoints3 = {{-30,-30,0}, {-30,-10,0}, {-10,-30,0}, {-10,-10,0}}; new ICurve(controlPoints3).clr(0,0.5,1.); // degree 2 curve double[][] controlPoints4 = {{0,-30,0}, {0,-10,0}, {20,-30,0}, {20,-10,0}}; new ICurve(controlPoints4,2).clr(.5,0,1.); // degree 3 curve double[][] controlPoints5 = {{30,-30,0}, {30,-10,0}, {50,-30,0}, {50,-10,0}};
new ICurve(controlPoints5,3).clr(1.,0,1.);