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 tricky to compute. This task involves writing a new callback function that takes an rt_db_internal object and calculates its centroid (as a point_t 3D point). There are numerous examples in our code where we compute centroids for other primtiives. The primitives that do not already have a centroid callback are itemized in following. References:
Code:
|
File name/URL | File size | Date submitted | |
---|---|---|---|
table.c | 35.8 KB | December 05 2012 23:19 UTC | |
hyp.c | 39.0 KB | December 05 2012 23:20 UTC | |
hyp.c.diff | 400 bytes | December 07 2012 05:15 UTC | |
table.c.diff | 198 bytes | December 07 2012 05:15 UTC | |
new2.patch | 943 bytes | December 07 2012 10:35 UTC | |
new3.patch | 987 bytes | December 08 2012 03:41 UTC | |
new4.patch | 922 bytes | December 08 2012 05:09 UTC |
I would like to work on this task.
This task has been assigned to Aaron Keesing. You have 72 hours to complete this task, good luck!
I see that there is a point_t object in the rt_hyp_internal structure whose description is "hyp vertex". Does this mean that all I have to do is make the centroid function replace *cent with hyp_Vi, like for rt_ell_centroid()?
I will upload that work but if you would like me to actually calculate the centroid within the function then I will see if I can do that.
Thanks
Aaron K
The work on this task is ready to be reviewed.
Please provide us one. Your subversion client should be able to generate it.
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.
The work on this task is ready to be reviewed.
So a few problems. First and foremost, it looks like the centroid is wrong. It's not just the Vi point as that's on the base.
Next, the indentation is wrong in the hyp.c file. See our HACKING file or other source files for details and examples.
The other issue is more practical, don't submit patches as separate files. The changes to both files can be combined into a single patch file. "svn diff file1.c file2.c ... my.patch" and similarly with the other GUI-based SVN tols too.
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.
The work on this task is ready to be reviewed.
I only uploaded the patch file this time, so hyp.c and table.c are still my original ones. I think I have also fixed the indentation problem; I was using tabs instead of spaces.
Looking at the code already in hyp.c I believe the centroid has already been calculated somewhere. I believe it is in the hyp_internal_to_specific() function, where the full height vector is halved and added to the Vi point. This should give the center of the hyperboloid. I only used the two statements in that function that I needed and transferred them to the centroid function, to save unnecessary computation time.
If you want me to upload the newest hyp and table c files I will do that.
Thanks
Aaron K
[ 27%] Building C object src/librt/CMakeFiles/librt.dir/primitives/hyp/hyp.c.o
/home/rossberg/Devel/brlcad/src/librt/primitives/hyp/hyp.c: In function ‘rt_hyp_centroid’:
/home/rossberg/Devel/brlcad/src/librt/primitives/hyp/hyp.c:1370:5: error: ISO C90 forbids mixed declarations and code [-Werror=edantic]
cc1: all warnings being treated as errors
make[2]: *** [src/librt/CMakeFiles/librt.dir/primitives/hyp/hyp.c.o] Fehler 1
make[1]: *** [src/librt/CMakeFiles/librt.dir/all] Fehler 2
make: *** [all] Fehler 2
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.
Aaron, I suggest looking that function over again and noting the object types. I may be mistaken as I only did a quick check, but I think you're confusing the V field on one struct with the Vi field on a different struct. Make a hyp yourself and print out the value. The "center" or "lookat" commands in mged will help.
The deadline of the task has been extended with 1 days and 0 hours.
The work on this task is ready to be reviewed.
Sean, I'm not sure exactly what you mean when you suggest I might be confusing object types. I think I have solved the build crash issue as when I built it it did not come up with any hyp related errors (although I was building it on Windows). The description of hyp_V is "scaled vector to hyp origin". I interpreted that, after looking at the code, as being the center of the hyperboloid.
Regards
Aaron K
Aaron, so the distinction comes down to what fields are in a hyp_specific struct and which are in an rt_hyp_internal struct. You do mimic another bit of code, which is probably what caused some misunderstanding earlier. You add half the height vector to the hyp_Vi base center point, which indeed does give that center point.
The main issue remaining is that you don't actually need hyp_specific, it's superfluous. You should be working entirely with just *cent (which isn't 'centroid' why?) or use a point_t instead. The issues I see are:
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.
The work on this task is ready to be reviewed.
I think I have fixed all the issues you mentioned. I wasn't sure exactly how to implement the null checking, so I just made it return if either argument was NULL. If this is bad please let me know so I can fix it.
Thanks
Aaron K
What you did looks good now. Thanks for going through the revisions to get it fixed up!
Congratulations, this task has been completed successfully.
A follow-on task has been created:
http://www.google-melange.com/gci/task/view/google/gci2012/8087202
Aaron, your changes have been applied to our repository (r54062) and your name recorded in our authorship documentation. You'll be credited with this publicly visible change in our next public release of BRL-CAD too. Thank you for your efforts!
As GCI comes to a close, we wanted to take the time to say THANK YOU for all your efforts. This comment interface closes after GCI is over, so you're encouraged to join our mailing list where we'll be announcing contributions from GCI participants like yourelf over the upcoming months:
https://lists.sourceforge.net/lists/listinfo/brlcad-news
If you've provided your full name, we'll be sure to credit you in our authorship documentation and you'll see your name in a future announcement. If you contact us at devs@brlcad.org or via IRC, we'll even let you know when your work is integrated and follow up with updates. You're welcome and encouraged to contact us any time, especially if you have a question about how to continue participating in Open Source after GCI is over, but even if just to keep in touch. Note that ongoing participation in Open Source is one of the most impressive skills to have on your resumé. Take care, be well, and thank you again!