Reputation: 2313
Here is my calculations for a circular (regular) cylinder
volume = Math.PI * Math.pow(length / 2.0, 2) * depth;
Here are my calculations for an elliptical cylinder
volume = Math.PI * Math.pow(length * width, 2) * depth;
When I run it as a circle it comes out fine, but when I run it as an oval it returns a huge number. I'm not sure if my calculations are wrong or what.
Upvotes: 0
Views: 1136
Reputation: 5156
Mike,
Test your formula against Wolfram Alpha:
http://www.wolframalpha.com/entities/calculators/elliptic_cylinder_volume/1n/ld/39/
Remember that:
Upvotes: 0
Reputation: 17306
Off the top, the volume for the oval (elliptical cylinder) is not correct dimensionally. It should be
volume = Math.PI * (length * width) / 4.0 * depth;
Upvotes: 2
Reputation: 82589
volume = Math.PI * length * width * depth / 4; // div by 4
It's really (length/2) * (width/2), but we can simplify it to (length * width / 4)
Upvotes: 2