8000 Move Vec3d to its own files by isaacbrodsky · Pull Request #67 · uber/h3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 4 commits into from
Jun 5, 2018
Merged

Conversation

isaacbrodsky
Copy link
Collaborator

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. :)

@coveralls
Copy link
coveralls commented Jun 1, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 5e99e40 on isaacbrodsky:move-vec3d into f24c8a6 on uber:master.

Copy link
Collaborator
@nrabinowitz nrabinowitz left a 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(&centerCoords, &centerPoint);
printf("{%.16f, %.16f, %.16f}, // face %2d\n", centerPoint.x,
Copy link
Collaborator

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?

Copy link
Collaborator Author

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) {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Contributor

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) {
Copy link
Collaborator

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};
Copy link
Collaborator

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"> Copy link
Collaborator Author

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] = {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake. Looks good.

@nrabinowitz
Copy link
Collaborator

Thanks for the explanations, @isaacbrodsky!

Copy link
Contributor
@isaachier isaachier left a 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] = {
Copy link
Contributor

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.

Copy link
Contributor
@isaachier isaachier left a 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] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake. Looks good.

@isaacbrodsky isaacbrodsky merged commit abbc693 into uber:master Jun 5, 2018
@isaacbrodsky isaacbrodsky deleted the move-vec3d branch June 5, 2018 00:24
mrdvt92 pushed a commit to mrdvt92/h3 that referenced this pull request Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0