BRL-CAD provides more than two dozen types of geometry "primitives" such as ellipsoids, boxes, and cones. Every primitive is described by a collection of callback functions, for example rt_ell_bbox() returns the bounding box dimensions for an ellipsoid. Wikipedia, Wolfram Mathworld, and various other math sites (and research papers) around the web include the equations for most of our basic primitives while others are a little more difficult to compute. This task involves writing a new callback function that takes an rt_db_internal object and calculates the volume (units are mm^3). There are numerous examples in our code where we compute volume for other primitives. The primitives that do not already have a volume callback are itemized in following. References:
Code:
|
File name/URL | File size | Date submitted | |
---|---|---|---|
hyp.c | 38.9 KB | November 30 2012 22:16 UTC | |
hyp.c | 38.9 KB | November 30 2012 22:16 UTC | |
hyp.c | 39.0 KB | December 01 2012 02:13 UTC | |
hypvolume.patch | 1.8 KB | December 14 2012 04:54 UTC |
I would like to work on this task.
I'm not sure if I have the ability to assign this task to you or not, but I will be happy to mentor it when it is assigned.
-Matt
This task has been assigned to Ben Bray. You have 72 hours to complete this task, good luck!
Matt, not only do you have the ability to assign the task (select the assign task button), you have the ability to assign yourself as a mentor too (select the edit task button). That goes for ANY task that interests you. ;)
Cheers!
Ah, I see. OK, I'll stick my name on a few things shortly. Thanks!
-Matt
The work on this task is ready to be reviewed.
This looks good, but I don't have time to actually properly check this for at least a few hours. I'm extending the deadline in order to give myself fime to go over this a little later. Of course, somebody else may get around to it first...
-Matt
The deadline of the task has been extended with 0 days and 12 hours.
I updated the file with code that I believe is more preferrable. Instead of calling hyp_internal_to_specific() in each call to rt_volume(), I replaced the method call with just the code that I needed. No more unnecessary calculations.
- Ben
Melange has detected that the deadline has passed and no more work can be submitted. The submitted work should be reviewed.
First, I cannot figure out how to actually call this function, so I cannot test it. How have you managed to do it?
Second, the most recent version (Dec. 01) does not compile, whereas the older one (Nov. 30) compiles without any issues. Hooray!
Finally, I think there is a computational error in your code. Using your notation, the volume should be:
*vol = M_PI * h * r1 * r1 * (1 + ( (h * h) / (12 * c * c)));
should it not? So, if you want to fix this, and tell me how you have called it, I'll re-open the task for you.
Cheers!
This approach will not be totally compatible with the hyp primitive anyway, as the parameter "B" used in defining a hyp primitave allows for an elliptical cross section, not just circular ones. I didn't actually notice this at first--my bad!
Thus, your function is actually going to require quite a bit more effort I'm afraid, this version will only ever work when B = 1.
One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.
I wasn't able to figure out how to call the method, either. There isn't much documentation, I'm afraid. Have you figured out how to call it yet?
The rtweight command is supposed to return the volume of shapes, but I can't figure out how to get rtweight to work either; when I pass it a *.r file it gives me errors.
I'll modify my code to work with cases where B 1.
The claim on this task has been removed, someone else can claim it now.
I would like to work on this task.
I noticed there was another identically named and described task as well, so what is the difference between this one and that one?
Aaron K
This task has been assigned to Aaron Keesing. You have 72 hours to complete this task, good luck!
Aaron, I don't know whats the difference between these two tasks. I think, the intention was to split this task in two or more parts becasuse of the mathematical difficulty. You should know that a HYP is something similar to http://mathworld.wolfram.com/EllipticHyperboloid.html
Any progress in calculating the HYP primitive's volume would make this task count as completed. However, the first steps is to develop the formula as there is no handy yet.
Also, for what it's worth, I've sketched up a possible solution strategy here:
http://brlcad.org/wiki/Image:Volume_computation.pdf
I'm not sure it's correct though--it was done in a rush and I have not worked all the way through it. But it may be a start...
Matt, I looked at your volume computation PDF, but surely there must be some easier way of calculating the volume. Are you not able to find the volume by integration of cross-sectional area. Using basic calculus, I integrated the function for cross-sectional area from 0 to h/2 (if hyp is oriented in z and has center at 0), then multiplied this by 2 to get the formula:
V = pi*a*b*h*(1 + (h^2)/(12*c^2)).
This was using the standard formula for a hyperboloid of x^2/a^2 + y^2/b^2 - z^2/c^2 = 1; the formula described in hyp.c has a slightly different formula. But the formula for the volume should still be somewhat similar.
But I don't think it's what you've suggested. Maybe it is though. Let's investigate, shall we?
You're saying that youor volume element is:
dV = A(z)dz
=\pi * r1(z) * r2(z) * dz
where r1(z) and r2(z) are the major and minor axes of the ellipse, determined via
(x^2 / a^2) + (y^2 / b^2) - (z^2/c^2) = 1
and your'e saying this leads to your provided formula for V? Please do show me how--I'm not saying you're incorrect, I'm saying I don't have time this minute to work through the computations right now. And I won't have the time in the next while either...
Cheers!
I have created a document which hopefully shows you how I came to my formula for the volume:
https://docs.google.com/open?id=0BydeQ6BPlVejRTFyRkFlbWNXNjQ
Regards
Aaron K
Melange has detected that the initial deadline has passed and it has set the task status to ActionNeeded. The student has 24 hours to submit the work before the task is reopened and sent back to the pool for other students to claim.
The deadline of the task has been extended with 1 days and 0 hours.
It'll take some time to digest that, but I added more time just to keep the clock rolling. Matt and Daniel are both better at reviewing the math tasks faster than I can (takes me forever to get everything into context). :)
Of course, there's always the demonstrative approach. Create a HYP with a known volume (e.g., where it equals an RCC), and show it works by comparison. If we run out of review time, we can accept the task and create another for someone to test it (but at the risk of the code getting ranked wholesale if it doesn't work).
I havn't checked every step but the approach with the integral shows how it should work. Maybe Matt should have a look at it too and correct me if I'm wrong.
The next steps (in different tasks) would be to
Aaron, if it's not completed I can't close it ;)
The work on this task is ready to be reviewed.
I've tested the formula using a cylinder like Sean said, although I only tested it twice.
I've submitted the code (which includes the centroid function I did for a previous task) as hypvolume.patch
Aaron K
The code has some shortfalls in my opinion but for a GCI task enough work was invested here. Additional efforts need to be made in an additional task (e.g. in the twin of this one).
Congratulations, this task has been completed successfully.
A follow-on task for this work has been created:
http://www.google-melange.com/gci/task/view/google/gci2012/8074203