1. Where did you set your projection?  In the MapBasic window (i.e. using
Run Command) or directly in your application (in line Set Coordsys
statement)?   I've been burned by this more than once and now always do
both.

2. There's no need to calculate angles for your application.  Trig functions
are approximations and introduce errors.  Instead, use ordinary analytic
geometry to get X and Y coordinates for points between nodes.

3. Is the projection appropriate for these calculations?.  With a conformal
projection you can use ordinary Cartesian geometry rather than spherical
geometry. Add a Bounds clause to your Coordsys clause to get maximum
coordinate granularity.

4. Arcsin has accuracy issues (small changes arising from coordinate
granularity result in large changes in the result) in parts of its domain.
To calculate an azimuth ase Atan2 or a function that simulates it.

HTH
Spencer

PS
Hope the code below helps.  Don't blame me if it doesn't compile.
S
 

Function intser (ByVal x1 as float, 
                 ByVal y1 as float,
                 ByVal x2 as float,
                 ByVal y2 as float,
                 ByVal inc as float,
                       rx (0) as float,
                       ry (0) as float) as smallint

Dim dx as float
Dim dy as float
Dim m as float
Dim ct as smallint
Dim i as smallint
Dim z as float

Dx = x2 - x1
Dy = y2 - y1
m = dx*dx+dy*dy
If m < inc*inc
   then intser=0
   else m = sqr (m)
        dx = dx / m
        dy = dy / m
        inc = abs(inc)
        ct = int(m / inc)
        z = (m - ct*inc)/2
        if z < inc/4
           then ct=ct-1
                z=z+inc/2
        end if    
        redim rx (ct)
        redim ry (ct)
        for i = 1 to ct
            rx (i) = x1+dx*z
            ry (i) = y1+dy*z
            z = z + inc
        next
        intser = ct
End if
End function

 
function atan2 (ByVal dx as float, 
                ByVal dy as float) as float

dim a as float

If (abs (dx) > abs (dy)) 
   then a = atn (dy/dx)
   else a = atn (dx/dy)
        if a < 0
           then a = PI/2-a
           else a = -PI/2-a
        end if
End if
if dx < 0
   then if dy < 0
           then a = a - PI
           else a = a + PI
        end if
        atan2 = a
end if
end function

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 


Given a set of points (specifically, a hurricane track) I am trying to
select one point in sequence, then the next point in sequence, extract the
angle and distance between the two, and then create intermediate points
using the Offset function, the angle, and a fractional portion of the
distance.

 

I'm using 

 

ANGL =
Asin(Distance(F_XX2,F_YY2,F_XX2,F_YY1,"mi")/Distance(F_XX1,F_YY1,F_XX2,F_YY2
,"mi"))* RAD_2_DEG

 

to measure the angle, where F_ANGL is the angle, F_XX2 is the CentroidX of
the second point, F_YY2 is the CentroidY of the second point, F_XX1 is the
CentroidX of the first point, and F_YY1 is the CentroidY of the first point.
All variables (in this instance) are float values,

 

To make a long story short, my program ran perfectly on what set of data,
creating the intermediate points perfectly.  On the other hand, it didn't
work on a second set of data, even though the projections (between the first
and second set) were the same.  Rather than neatly falling between the first
and second points, as in the first dataset, the intermediate points were
skewed off in the another direction.  Anyone have any ideas what is
happening here?

 

Thanks much,

Mike Jenne



_______________________________________________
MapInfo-L mailing list
MapInfo-L@lists.directionsmag.com
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to