// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - private static IExpression ParseMultExpression() { if (Check(FirstExpExp)) { IExpression exp = ParseExpExpression(); while (Check(new TokenSet(TokenType.Multiply | TokenType.Divide))) { TokenType opType = CurrentToken.type; Eat(opType); if (!Check(FirstExpExp)) { throw new InvalidSyntaxException("Expected an expression after * or / operator"); } IExpression 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); } else { 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 ) ) { IExpression exp = ParseExpExpression(); while ( Check( new TokenSet( TokenType.Multiply | TokenType.Divide ) ) ) { TokenType opType = CurrentToken.type; Eat( opType ); if ( !Check( FirstExpExp ) ) { throw new InvalidSyntaxException( "Expected an expression after * or / operator" ); } IExpression 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; } else { throw new InvalidSyntaxException( "Invalid expression" ); } }