# Untitled

Okay, so I've been tinkering around with OO representations of mathematical expressions. And I think I'm going to make some simplifications for my prototype parser/renderer, but I can deal with that (details to follow).

Given the expression

You should immediately notice that this describes the unit sphere (dur), which isn't a function. One of the many methods I'm considering using to cripple this is to limit the input to functions, such that for any pair (x,y) there exists only one output z.

Thus, the above expression becomes

The most obvious disadvantage to this is that our nice little expression for a sphere becomes this distorted crazah set of equations. So yeah. Deal with it for now I guess.

That said, the parser consists of three main "ideas"/components.

Taking

That's nice and clean, but the rest of it gets ugly. Very ugly. Even by my standards -

parses to

Which, although it does seem kind of easy to parse since I've passed it nicely organized input with all the order-of-operations laid out for it. It shouldn't be _that_ hard to parse it without - just search left-to-right looking for operators.

Which is exactly the part I'm not looking forward to - searching around a string looking for yummy details to parse. We'll see what happens...

[ ^_^ ]/[ O_o ]

Given the expression

`x^2 + y^2 + z^2 = 1`You should immediately notice that this describes the unit sphere (dur), which isn't a function. One of the many methods I'm considering using to cripple this is to limit the input to functions, such that for any pair (x,y) there exists only one output z.

Thus, the above expression becomes

`f1(x,y) = ( 1 - x^2 - y^2 ) ^ ( 1/2 )`

f2(x,y) = - ( 1 - x^2 - y^2 ) ^ ( 1/2 )f2(x,y) = - ( 1 - x^2 - y^2 ) ^ ( 1/2 )

The most obvious disadvantage to this is that our nice little expression for a sphere becomes this distorted crazah set of equations. So yeah. Deal with it for now I guess.

That said, the parser consists of three main "ideas"/components.

- a construct which represents a value in an expression, whether its a variable or a constant, or whatever.`Values`- a pair of values and/or expressions combined with an operation.`Expressions`- a list of expressions and/or statements which operate on one another.`Statement`

Taking

`f1`from above, we can parse it like -`f1( x, y ) =`// defines a statement f1.That's nice and clean, but the rest of it gets ugly. Very ugly. Even by my standards -

`( ( ( (1) - (x^2) ) - (y^2) ) ) ^ (1/2)`parses to

Quote:

expression( expression( expression( value(1) minus expression( value(x) power value(2) ) minus expression( value(y) power value(2) ) ) power expression( value(1) divided by value(2) )

Which, although it does seem kind of easy to parse since I've passed it nicely organized input with all the order-of-operations laid out for it. It shouldn't be _that_ hard to parse it without - just search left-to-right looking for operators.

Which is exactly the part I'm not looking forward to - searching around a string looking for yummy details to parse. We'll see what happens...

[ ^_^ ]/[ O_o ]

Sign in to follow this

Followers
0

## 2 Comments

## Recommended Comments

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account## Sign in

Already have an account? Sign in here.

Sign In Now