-
Notifications
You must be signed in to change notification settings - Fork 503
Move Vec3d to its own files #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - most of my questions here are just for my edification :).
GeoCoord centerCoords = faceCenterGeo[i]; | ||
Vec3d centerPoint; | ||
_geoToVec3d(¢erCoords, ¢erPoint); | ||
printf("{%.16f, %.16f, %.16f}, // face %2d\n", centerPoint.x, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Do you need leading spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just left them for clang-format to insert. I see in the base cell neighbors generator it does have the spaces, I'll add them here for consistency.
|
||
int main(int argc, char* argv[]) { | ||
// check command line args | ||
if (argc > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any need for this block, when the script takes no args?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just checks that no (unused) args were provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as other review (#69), you can always do int main(void)
in this case. No need to be "strict" about it.
|
||
BEGIN_TESTS(Vec3d); | ||
|
||
TEST(_pointSquareDist) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding tests!
} | ||
|
||
TEST(_geoToVec3d) { | ||
Vec3d origin = {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my info - why not {0, 0, 0}
? Doesn't this result in undefined memory for the uninitialized struct fields? Or is this functionally equivalent to {0, 0, 0}
?
<
8000
svg aria-label="Show options" role="img" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-kebab-horizontal">
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this should be the same as initializing all members to 0, https://stackoverflow.com/questions/11152160/initializing-a-struct-to-0
|
||
/** square root of 7 */ | ||
#define M_SQRT7 2.6457513110645905905016157536392604257102L | ||
|
||
/** @brief icosahedron face centers in lat/lon radians */ | ||
static const GeoCoord faceCenterGeo[NUM_ICOSA_FACES] = { | ||
const GeoCoord faceCenterGeo[NUM_ICOSA_FACES] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my info: Why drop static
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Static is incompatible with extern, because a static variable would only be visible within the same compilation unit (think .c file) and extern is needed for the generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need extern
here if this is declared extern
in a header file, which is the case here. I'd remove the extern
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake. Looks good.
5cca316
to
20ca294
Compare
Thanks for the explanations, @isaacbrodsky! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment.
|
||
/** square root of 7 */ | ||
#define M_SQRT7 2.6457513110645905905016157536392604257102L | ||
|
||
/** @brief icosahedron face centers in lat/lon radians */ | ||
static const GeoCoord faceCenterGeo[NUM_ICOSA_FACES] = { | ||
const GeoCoord faceCenterGeo[NUM_ICOSA_FACES] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need extern
here if this is declared extern
in a header file, which is the case here. I'd remove the extern
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
/** square root of 7 */ | ||
#define M_SQRT7 2.6457513110645905905016157536392604257102L | ||
|
||
/** @brief icosahedron face centers in lat/lon radians */ | ||
static const GeoCoord faceCenterGeo[NUM_ICOSA_FACES] = { | ||
const GeoCoord faceCenterGeo[NUM_ICOSA_FACES] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake. Looks good.
Move Vec3d to its own files
Follow up to @wewei's PR #63. Vec3d is moved to a new file, and added a few simple tests of those functions directly.
I added a
generateFaceCenterPoint
program since I like being able to regenerate tables in the library easily. :)