// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - private static IExpression ParseMultExpression() { if (Check(FirstExpExp)) { var exp = ParseExpExpression(); while (Check(new TokenSet(TokenType.Multiply | TokenType.Divide))) { var opType = _currentToken.Type; Eat(opType); if (!Check(FirstExpExp)) { throw new InvalidSyntaxException("Expected an expression after * or / operator"); } var right = ParseExpExpression(); switch (opType) { case TokenType.Multiply: exp = new MultExpression(exp, right); break; case TokenType.Divide: exp = new DivExpression(exp, right); break; default: throw new UnexpectedBehaviorException("Expected mult or divide, got: " + opType); } } return(exp); } throw new InvalidSyntaxException("Invalid expression"); }
public Cone(double radius, double height) { IExpression fx = new MultExpression( new MultExpression( new SubExpression( new ConstantExpression(height), new VariableExpression("v")), new ConstantExpression(radius/height)), new CosineExpression( new VariableExpression("u"))); IExpression fy = new VariableExpression("v"); IExpression fz = new MultExpression( new MultExpression( new SubExpression( new ConstantExpression(height), new VariableExpression("v")), new ConstantExpression(radius/height)), new SineExpression( new NegateExpression( new VariableExpression("u")))); Init(fx, fy, fz, -Math.PI, Math.PI, 0.0, height); }
public Cone(double radius, double height) { IExpression fx = new MultExpression( new MultExpression( new SubExpression( new ConstantExpression(height), new VariableExpression("v")), new ConstantExpression(radius / height)), new CosineExpression( new VariableExpression("u"))); IExpression fy = new VariableExpression("v"); IExpression fz = new MultExpression( new MultExpression( new SubExpression( new ConstantExpression(height), new VariableExpression("v")), new ConstantExpression(radius / height)), new SineExpression( new NegateExpression( new VariableExpression("u")))); Init(fx, fy, fz, -Math.PI, Math.PI, 0.0, height); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - private static IExpression ParseMultExpression() { if (Check(FirstExpExp)) { var exp = ParseExpExpression(); while (Check(new TokenSet(TokenType.Multiply | TokenType.Divide))) { var opType = _currentToken.Type; Eat(opType); if (!Check(FirstExpExp)) { throw new InvalidSyntaxException("Expected an expression after * or / operator"); } var right = ParseExpExpression(); switch (opType) { case TokenType.Multiply: exp = new MultExpression(exp, right); break; case TokenType.Divide: exp = new DivExpression(exp, right); break; default: throw new UnexpectedBehaviorException("Expected mult or divide, got: " + opType); } } return exp; } throw new InvalidSyntaxException("Invalid expression"); }