Hi Khurram

The algorithm for lat/long to linear can be found on the Ordnance Survey
website (www.ordsvy.gov.uk) It is in a pdf called "A Guide To British
Coordinate Systems" - and theres a spreadsheet that implements the
algorithm. Its OSGB but the algorithm is universal. You can replace the
false orgins, scale factor etc to fit your required coordinate system.

There follows a VB implementation of a circles intersection algorithm - the
clsPoint referred to is just a simple class (which could be a type) storing
an x and y.

HTH

Rgds

Paul

'Checks for intersections between two circles
'and then draws one or two points
'NB
' Matrix  used to perform transformation
'    --             --     --   --
'    |  cos_t  sin_t |     | c2x |
'    | -sin_t  cos_t |  *  | c2y |
'    --             --     --   --

Public Sub CalcIntersectionOfCircles(ByVal pt1 As clsPoint, _
                                            ByVal Rad1 As Double, _
                                            ByVal pt2 As clsPoint, _
                                            ByVal Rad2 As Double, _
                                            ByRef intersectpt1 As clsPoint,
_
                                            ByRef intersectpt2 As clsPoint)

    Dim delta_x As Double
    Dim delta_y As Double
    Dim c1x As Double
    Dim c2x As Double
    Dim c1y As Double
    Dim c2y As Double
    Dim distCenters As Double '/* distance between the centers */
    Dim X As Double '/* used for checking */
    Dim Y As Double
    Dim R As Double
    Dim diff As Double
    Dim offset_x As Double ' /* the offset's to move to the origin */
    Dim offset_y As Double
    Dim t As Double '/* t is the angle between the second center and the
horizontal after move to the origin */
    Dim tan_t As Double
    Dim cos_t As Double
    Dim sin_t As Double
    Dim xLeft As Double
    Dim yBelow As Double
    Dim xint As Double
    Dim yint1 As Double
    Dim yint2 As Double
    Dim p1x As Double
    Dim p1y As Double
    Dim p2x As Double
    Dim p2y As Double
   
    Const M_PI As Double = 3.14192654 'Better value may be available
    Const PROC_NAME = "CalcIntersectionOfCircles"
   
    On Error GoTo ErrorHandler


     'Extract input params
    
    c1x = pt1.X
    c1y = pt1.Y
    c2x = pt2.X
    c2y = pt2.Y
    
    delta_x = c2x - c1x
    delta_y = c2y - c1y
    
    distCenters = CDbl(Sqr(((delta_x * delta_x) + (delta_y * delta_y))))
    If distCenters > 0 Then
        '
        ' Assume that the first circle center lies on the origin and the
second lies on the x axis dist
        ' Centers from the origin.
        ' Calculate the intersections for the new configuration using rad1,
rad2 and distCenters
        '
        
        'X = (Rad1 - Rad2 + distCenters) / (2 * distCenters)
        'Y = Sqr(Rad1 - X)
        '  ie ve And -ve ' PC note - not being used?
        '*/
        '
        'xint = cdbl((((Rad1 * Rad1) - (Rad2 * Rad2) + (distCenters *
distCenters)) / (2 * distCenters)))
        X = (Rad1 * Rad1) - (Rad2 * Rad2) ' Using x as a temporary storage
and splitting evaluation over 3 lines
        Y = X + (distCenters * distCenters)
        xint = CDbl(Y / (2 * distCenters))
        
        X = (Rad1 * Rad1) - (xint * xint)
        If X > 0 Then
            yint1 = CDbl(Sqr(X))
            yint2 = 0 - yint1
            '
            '/* work out the angles for the transformation */
            If (delta_x <> 0) Then
                t = Atn(delta_y / delta_x)
                If (delta_x > 0) Then
                    t = (2 * M_PI) - t
                    If (t > (2 * M_PI)) Then
                            t = t - (2 * M_PI)
                    End If
                Else
                    t = M_PI - t
                End If
                sin_t = sIn(t)
                cos_t = Cos(t)
            
            Else
                cos_t = 0
                If (c2y > c1y) Then
                    sin_t = -1  '/* t is 90 degrees */
                Else
                    sin_t = 1 ' /* t is 270 degrees */
                End If
            End If
            
            '/* Rotate the second center about 0,0 */
            p1x = (xint * cos_t) + (yint1 * sin_t)
            p1y = (0 - (xint * sin_t)) + (yint1 * cos_t)
            p2x = (xint * cos_t) + (yint2 * sin_t)
            p2y = (0 - (xint * sin_t)) + (yint2 * cos_t)
            '
            '  /* and then move them from the origin by c1x, c1y */
            p1x = p1x + c1x
            p1y = p1y + c1y
            p2x = p2x + c1x
            p2y = p2y + c1y
            
            intersectpt1.X = p1x
            intersectpt1.Y = p1y
            intersectpt2.X = p2x
            intersectpt2.Y = p2y
        End If
    End If

CalcIntersectionOfCircles_Cont:
      
    
    Exit Sub
   
ErrorHandler:
    
    Call mclsErrHdlr.HandleError(MODULE_NAME, MODULE_REVISION, PROC_NAME, _
                               ERROR_CATEGORY_HIGH, sParameters, sScene)
    Resume CalcIntersectionOfCircles_Cont

End Sub

Paul Crisp
Syntegra

Direct:  0191 461 4522 
Mobile: 0776 414 3762
Fax: (0191) 461 1959

Innovation Place Metro Riverside Park
Delta Bank Road Gateshead Tyne & Wear NE11 9DJ


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 07 January 2002 22:05
To: [EMAIL PROTECTED]
Subject: MI-L Lat/long to linear cord.



Hi all,

I like to convert Mapinfo lat/long cordinates into linear cordinate system
say cartesian cord, and vice versa. I need to get the pints of intersection
between two circles with a given radius and ceneroid. I was thinking to
solve it in cartesian cordinate by using circle equattion, instead of doing
it graphically in mapinfo. Once I can do that I will then easily map  it
with the respective data columns. Please let me know any algorithum to
perform the conversion. OR if its not a good idea.

Thanks,



_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.


********************************************************************

This email may contain information which is privileged or confidential. If you are not 
the intended recipient of this email, please notify the sender immediately and delete 
it without reading, copying, storing, forwarding or disclosing its contents to any 
other person
Thank you

Check us out at http://www.syntegra.com

********************************************************************



_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.

Reply via email to