Implement a primitive centroid function ... for polyhedron with 4 to 8 sides (ARB8)BRL-CAD
Status: ClosedTime to complete: 72 hrs Mentors: Sean, Matt S.Tags: C, C++, math, geometry, centroid

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:

  • src/librt/primitives/table.c
  • src/librt/primitives/arb8/arb8.c
Uploaded Work
File name/URLFile sizeDate submitted
arbcent.patch1.6 KBDecember 03 2012 05:23 UTC
centroidv2.patch1.9 KBDecember 03 2012 11:23 UTC
centroid.patch1.8 KBDecember 03 2012 12:55 UTC
centroidone3.2 KBDecember 03 2012 13:18 UTC
centroidone.patch3.2 KBDecember 03 2012 14:55 UTC
finalcentroid.patch4.0 KBDecember 03 2012 16:47 UTC
finallycentroid.patch4.0 KBDecember 03 2012 20:23 UTC
Comments
Ashwin Lokkuron November 27 2012 17:14 UTCTask Claimed

I would like to work on this task.

Sean on November 27 2012 17:35 UTCTask Assigned

This task has been assigned to Ashwin Lokkur. You have 72 hours to complete this task, good luck!

Ashwin Lokkuron November 30 2012 15:08 UTCClaim Removed

The claim on this task has been removed, someone else can claim it now.

Ashwin Lokkuron November 30 2012 15:08 UTCTask Claimed

I would like to work on this task.

Ashwin Lokkuron November 30 2012 15:08 UTCClaim Removed

The claim on this task has been removed, someone else can claim it now.

Ashwin Lokkuron November 30 2012 15:09 UTCSorry

I couldn't work on the task... I had my exams coming up :(


 

Sean on December 2 2012 05:42 UTCit's alright

You don't have to apologize. ;)


Thank you for your interest.  If you (or anyone else) would like to try again, the task is still available to be claimed.

Silvrouson December 3 2012 03:59 UTCTask Claimed

I would like to work on this task.

Silvrouson December 3 2012 04:02 UTCalready exists

There is a centroid function defined already in arb8.c.I assume it is non functional and I have to replace it?

Sean on December 3 2012 05:15 UTCTask Assigned

This task has been assigned to Silvrous. You have 72 hours to complete this task, good luck!

Sean on December 3 2012 05:18 UTCat a glance

That would be an odd assumption to make.  I don't know if it's right or wrong, but it's certainly not the right function signature for being added to table.c -- you should certainly merge it with your work or eliminate it, just don't ignore it.

Silvrouson December 3 2012 05:23 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 3 2012 05:38 UTCTask Needs More Work

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.

Sean on December 3 2012 05:40 UTCstyle and hooking it in

Couple problems.  Your patch doesn't follow our coding guidelines (see the HACKING file) particularly w.r.t. space around operators.


Also, you don't hook the new function into the callback table.

Silvrouson December 3 2012 11:24 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on December 3 2012 12:09 UTCDon't count on C99

In every block you have to declare all variables first before any other operation.  Not all supported compilers are C99 conform, e.g. MS Visual Studio C/C++.


Daniel

Daniel Rossberg on December 3 2012 12:09 UTCTask Needs More Work

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.

Daniel Rossberg on December 3 2012 12:13 UTC... sorry

I've just recognized that the check was removed.

Silvrouson December 3 2012 12:18 UTCso

I can re-close it?

Silvrouson December 3 2012 12:19 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on December 3 2012 12:43 UTCcrash in analyze (mged)

You have changed the rt_arb_centroid() parameters.  Therefore you should change every use of this function accordingly.

Daniel Rossberg on December 3 2012 12:43 UTCTask Needs More Work

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.

Silvrouson December 3 2012 13:19 UTCdone

I'd realized the problem before reading your comment, and tried making separate functions first, then corrected the parameters.


The correct patch is centroidone.patch .


 

Silvrouson December 3 2012 13:19 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on December 3 2012 16:00 UTCPlease fix include/raytrace.h too

There should be now the correct prototype.

Daniel Rossberg on December 3 2012 16:00 UTCTask Needs More Work

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.

Silvrouson December 3 2012 16:48 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on December 3 2012 20:07 UTCcode does not compile

src/librt/primitives/arb8/arb8.c:326:5: error: ISO C90 forbids mixed declarations and code [-Werror=edantic]

Daniel Rossberg on December 3 2012 20:07 UTCTask Needs More Work

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.

Silvrouson December 3 2012 20:58 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 4 2012 06:27 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on December 4 2012 06:32 UTCfollow-on task


We'll likely have a follow-on task to confirm that your implementation works (maybe a unit test), but it looks reasonable at a glance.  Thanks for your efforts including bonus points for cleaning up analyze command and identifying that existing centroid function while you were at it. ;)


 


Sean on December 14 2012 14:22 UTCfollow-on task

A follow-on task has been created:


http://www.google-melange.com/gci/task/view/google/gci2012/8086202