IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 22 years ago

Closed 22 years ago

Last modified 22 years ago

#212 closed defect (fixed)

psSphereGetOffset()

Reported by: gusciora@… Owned by: Paul Price
Priority: high Milestone:
Component: PSLib SDRS Version: unspecified
Severity: normal Keywords: IPP-doc
Cc:

Description

Does it make sense to have a psSphereOffsetMode argument? Can I assume that
this mode will always be PS_SPHERICAL?

If not, what should I do when that argument is PS_LINEAR? This function is
declared type *psSphere. It can not return a linear offset.

Also, can you give me a definition of the arg() function which is used in the
ADD to describe some of the coordinate transformations?

Change History (9)

comment:1 by robert.desonia@…, 22 years ago

bug_group: PSLib?IPP-doc?
Component: astrocode std
Keywords: IPP-doc added; PSLib removed
Owner: changed from robert.desonia@… to eugene
product: PSLibIPP-doc

comment:2 by robert.desonia@…, 22 years ago

bug_group: IPP-doc?PSLib?
Component: code stdastro
Keywords: PSLib added; IPP-doc removed
Owner: changed from eugene to Paul Price
product: IPP-docPSLib

comment:3 by robert.desonia@…, 22 years ago

bug_group: PSLib?IPP-doc?
Component: astroPSLib SDRS
Keywords: IPP-doc added; PSLib removed
product: PSLibIPP-doc

comment:4 by Paul Price, 22 years ago

Status: newassigned

"arg" is the same as "atan", except used for complex numbers. You should use
the "atan2" function in order to get the correct quadrant.

For a "spherical offset", one simply adds the offset values to the RA and Dec.
For a "linear offset", one must project onto the tangent plane, apply the
offset, and deproject.

The difference is only noticeable near the pole. In both cases, you need to
watch out for the boundaries.

comment:5 by gusciora@…, 22 years ago

Okay, I implemented:

float p_psArg(float x, float y) {

return((float) atan2((double) x, (double) y));

}

And, for "watch out for the boundaries", I'll make sure all "d" angles are less
than 90 degrees.

comment:6 by Paul Price, 22 years ago

Resolution: fixed
Status: assignedclosed

That's a waste of cycles. Ideally, just use "atan2" (I changed the ADD), or if
for some reason (which should be justified) you absolutely must use the word
"arg", then it may be a #define macro, but not a function.

comment:7 by gusciora@…, 22 years ago

I agree. I fully intend to macro it. I want to make sure I have the correct
function first, however. I didn't understand what you said about using atan2()
to get the correct quadrant.

comment:8 by Paul Price, 22 years ago

Say we have a point, (x,y) = (1,1) which is in the first quadrant. Then
atan2(y,x) is 45 degrees, and atan(y/x) is 45 degrees --- both correct.
However, if (x,y) = (-1,-1) which is in the third quadrant, then atan2(y,x) is
225 degrees (third quadrant), but atan(y/x) = 45 degrees (first quadrant) ---
atan produces the wrong answer, so you have to check which quadrant the point is
in (by examining the sign of x and y) in order to produce the correct answer.

The bottom line is that using "atan2" instead of "atan" saves you from writing
code to test which quadrant the point is in.

I would prefer you did not make a macro "arg" (additional code which must be
tested; obfuscation), but simply used "atan2".

comment:9 by gusciora@…, 22 years ago

Okay. Now I understand. atan2() requires no additional function calls. There
is, as you pointed out, no reason at all to use a macro.

I think we can close this bug.

Note: See TracTickets for help on using tickets.