Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/05/2010, 10:02
Avatar de mayid
mayid
Colaborador
 
Fecha de Ingreso: marzo-2009
Ubicación: BsAs
Mensajes: 4.014
Antigüedad: 16 años
Puntos: 101
Respuesta: do while y variable no reconocida

Ah! Ya entendí. El tema es que hay que declarar las variables antes de hacer el bucle. Igual tengo otra consulta:

Cita:
int numberSides;
double theta;
double radius;
double maxError;
double directionAngle;
double errorAngle;
double phi;
double angle;
double x1;
double y1;
double x2;
double y2;
double x3;
double y3;
double tolerance;


BRadioButton up;
BRadioButton down;
BRadioButton left;
BRadioButton right;

do
{
//Scene theScene = theWindow.getScene();

RadioButtonGroup directionType = new RadioButtonGroup();
up = new BRadioButton(Translate.text("up"), false, directionType);
down = new BRadioButton(Translate.text("down"), false, directionType);
left = new BRadioButton(Translate.text("left"), false, directionType);
right = new BRadioButton(Translate.text("right"), false, directionType);

GridContainer directional = new GridContainer(2, 2);
directional.setDefaultLayout(new LayoutInfo(LayoutInfo.WEST, LayoutInfo.NONE, new Insets(2, 2, 2, 2), null));
directional.add(up, 0, 0);
directional.add(down, 0, 1);
directional.add(left, 1, 0);
directional.add(right, 1, 1);

ValueField vertexValueField = new ValueField(45, ValueField.NONNEGATIVE);
ValueField radiusValueField = new ValueField(1.0, ValueField.NONNEGATIVE);
ValueField maxErrorValueField = new ValueField(0.05, ValueField.NONNEGATIVE);
ValueField directionValueField = new ValueField(0.0, ValueField.NONNEGATIVE);

ComponentsDialog dlg = new ComponentsDialog(theFrame, Translate.text("teardrop") ,
new Widget [] { directional, directionValueField, vertexValueField, radiusValueField, maxErrorValueField },
new String [] { Translate.text("zAxisOrientation") , Translate.text("zAxisRotation") , Translate.text("vertexAngle"), Translate.text("radius"), Translate.text("maxError") } );

if (!dlg.clickedOk()) return;

theta = vertexValueField.getValue() / 180 * Math.PI;
radius = radiusValueField.getValue();
maxError = maxErrorValueField.getValue();
directionAngle = directionValueField.getValue() / 180 * Math.PI;

errorAngle = Math.acos((radius - maxError) / radius); // inverse cosine

numberSides = Math.ceil(((2 * Math.PI) - 2 * (Math.PI / 2 - theta)) / errorAngle); // rounded up


if (numberSides <= 10)
new MessageDialog(theFrame, Translate.text("decreaseMaxError"));
}

while (numberSides < 10);
En el buble como está ahora tengo dos errores de compilación, que tienen que ver con tipos int y float, pero no se como solucionarlo (estoy usando codigo ajeno y soy nuevo en JAVA):

El error está aqui:
numberSides = Math.ceil(((2 * Math.PI) - 2 * (Math.PI / 2 - theta)) / errorAngle); // rounded up

Pero si cambio el tipo de numberSides no se soluciona. Alguien puede precisarme el problema? Y como discernir que tipo (int|float) necesito en cada caso?