Angle mask by angle

This commit is contained in:
Jesse Boyd 2017-03-10 08:26:16 +11:00
parent 1e90948581
commit 9cbe38359c
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 10 additions and 4 deletions

View File

@ -116,8 +116,6 @@ public class FawePrimitiveBinding extends BindingHelper {
if (input == null) {
return null;
}
System.out.println("PARSE " + input);
try {
return Double.parseDouble(input);
} catch (NumberFormatException e1) {

View File

@ -252,8 +252,16 @@ public class DefaultMaskParser extends FaweParser<Mask> {
throw new SuggestInputParseException(input, "/<min-angle>:<max-angle>");
}
try {
int y1 = (int) (Expression.compile(split[0]).evaluate());
int y2 = (int) (Expression.compile(split[1]).evaluate());
int y1,y2;
if (split[0].endsWith("d")) {
double y1d = Expression.compile(split[0].substring(0, split[0].length() - 1)).evaluate();
double y2d = Expression.compile(split[1].substring(0, split[1].length() - 1)).evaluate();
y1 = (int) Math.round(Math.tan(y1d * (Math.PI / 180)));
y2 = (int) Math.round(Math.tan(y2d * (Math.PI / 180)));
} else {
y1 = (int) (Expression.compile(split[0]).evaluate());
y2 = (int) (Expression.compile(split[1]).evaluate());
}
return new AngleMask(extent, y1, y2);
} catch (NumberFormatException | ExpressionException e) {
throw new SuggestInputParseException(input, "/<min-angle>:<max-angle>");