PerfectlyNormal
PerfectlyNormal

Reputation:

Calculating volumes of hollow three dimensional geometric objects

We've gotten a homework assignment in Java, which relates to inheritance. I don't have a problem with the programming in itself, but I'm a bit unsure about some of the math, and would like confirmation/corrections from someone a bit more knowledgable.

The assignment starts with a abstract class, GeometricObject, which is extended into three two-dimensional objects. A rectangle, a circle and a triangle. Those three are then extended into a cuboid for the rectangle, a cylinder and a sphere for the circle, and the triangle into a triangular prism.

Each of these three-dimensional objects are hollow, and has a defined thickness and is made of a special metal, so we are to calculate their weight. And herein lies the problem, since I'm a bit unsure as to how I find the "inner volume" on some of them.

Update: Forgot to mention that when creating the object, we specify the outmost sizes, and the hollow part is inside of this. The other way around is not allowed.

Update again: The triangle is an isosceles triangle.

Update yet again: Mixed up radius and diameter for the circular. Corrected now.

Upvotes: 0

Views: 5053

Answers (3)

jpalecek
jpalecek

Reputation: 47770

I think you cannot get this result from the data you have (baseline length & triangle height). You have to get other information, like location of the points or the angles at the baseline.

Edit: since the triangle is isosceles:

As AnthonyWJones already pointed out, the inner triangle is similar to the outer triangle. Therefore, the only thing you need is find the ratio between the two.

sketch http://img76.imageshack.us/img76/4164/g2654.png

You can find it easily from the height. Since triangles CQP and ACS are similar

h2 : |PQ| = |AC| : |AS|

where

|PQ| = h1 (= the thickness of the metal)
|AC| = sqrt(base^2/4+height^2)
|AS| = base/2

Then, you compute h2 and the ratio r = (height - h1 - h2)/height is the ratio between the two triangles. The area of the inner triangle is then r^2 * area of the outer triangle.

Upvotes: 3

AnthonyWJones
AnthonyWJones

Reputation: 189495

One thing you know about the inner prism is that it will have the same ratios as the outer prism. In other words given the height of the inner prism you can calculate the inner base length and from there the volume.

You know the base will have 1 unit thickness. So that leaves calculating the distance from the pinnacle of the inner prism to the pinnacle of the outer prism.

That distance is the hypontenuse of a right angled triangle. The angles in the triangle are known since they are function of the base length and height. One side of the triangle is of thickness length being the perpendicular from the inner edge at the inner pinnacle to the outer edge. (The final side of the triangle is where that perpendicular intersects the outer edge up to the outer pinnacle).

This is enough info to use standard trig to caclulate the hypotenuse length. This length plus 1 thickness (for the base) subtracted from the original height gives you the inner height. The ratio between the inner and outer heights can be applied to the base length.

There a probably cleverer ways to do this but this would be my common bloke approach.

Upvotes: 1

Sekhat
Sekhat

Reputation: 4479

Get the volume of the shapes as if they were not hollow, then, get the volume of the hollow are only (Shape - Thickness)

subtract full volume from hollow volume to get the actual volume of the metal.

Example:

Cube:

Full Volume: Height * Width * Depth

hollow volume: (Height - Thickness) * ( Width - Thickness ) * ( Depth - Thickness)

Volume of the metal used: Full Volume - hollow Volume

Work out the weight from the volume of the metal used..


Assuming your prism is triangular and the triangle is equilateral that the base line is the base of the triangle and the height is from the baseline to the opposite point (and the height line is at an right angle from the baseline).

Then the full volume would be

fv = (1/2 * baseLine * triangleHeight) * prismHeight 

the hollow volume would be

hv = (1/2 * (baseline - thickness) * (triangleHeight - thickness)) * (prismHeight - thickness)

After reading you comment to jpaleck, it would seem your baseline is the Hypotenuse of the triangle, (the longest line), the above should still hold true with that.


Upvotes: 1

Related Questions