Visual Basic

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Tutorialized ForumsDesktop ProgrammingVisual Basic

Add This Thread To:   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
Unread Tutorialized Forums Sponsor:
Old March 18th, 2010, 12:47 PM
preetisingh preetisingh is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
Join Date: Mar 2010
Posts: 1 preetisingh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 37 sec
Reputation Power: 0

I have a problem . I have to draw a circle at a particular distance say 50 meters from a given lat/log.I refered to Aviation formula's and find a formula to calculate lat/log at a distance and at a bearing which is as follows:-

A point {lat,lon} is a distance d out on the tc radial from point 1 if:

lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc)  )

     IF (cos(lat)=0)
        lon=lon1      // endpoint a pole

This algorithm is limited to distances such that dlon <pi/2, i.e those that extend around less than one quarter of the circumference of the earth in longitude. A completely general, but more complicated algorithm is necessary if greater distances are allowed:

lat =asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))


lon=mod( lon1-dlon +pi,2*pi )-pi

for this i have written this coding:-

Private Sub cmdNextPoint_Click()
Dim lat2 As Double, lon2 As Double, theta As Double, d As Double,Aasin As Double,Aatan2 As Double
Pi = 3.14159265358979
d = 50
theta = 90 * 0.0174532925
txtLatitude.Text = 22.51791
txtLongitude.Text = 87.46598
Aasin = Sin(Val(txtLatitude.Text)) * Cos(d) + Cos(Val(txtLatitude.Text)) * Sin(d) * Cos(theta)
lat2 = atan2(Aasin, Sqr(1 - Aasin * Aasin))
Aatan2 = Sin(theta) * Sin(d) * Cos(Val(txtLatitude.Text))
Batan2 = Cos(d) - Sin(Val(txtLatitude.Text)) * Sin(lat2)
lon2 = ((Val(txtLongitude.Text) - atan2(Aatan2, Batan2) + Pi) Mod (2 * Pi)) - Pi
txtLatitude2.Text = lat2
txtLongitude2.Text = lon2
End Sub

Public Function atan2(ByVal y As Double, ByVal x As Double) As Double
If y > 0 Then
If x >= y Then
atan2 = Atn(y / x)
ElseIf x <= -y Then
atan2 = Atn(y / x) + Pi
atan2 = Pi / 2 - Atn(x / y)
End If
If x >= -y Then
atan2 = Atn(y / x)
ElseIf x <= y Then
atan2 = Atn(y / x) - Pi
atan2 = -Atn(x / y) - Pi / 2
End If
End If
End Function

in this i m finding a point which is at a distance of 50 meters from the latitude 22.51791 and longitude 87.46598 and at a bearing of 90 degrees.Somebody told me that to draw a circle i have to find out 360 points then by using the DrawPolygon method the circle can be drawn.So firstly i m finding one point.It is not giving me the desired result that should be latitude = 22.51841 and longitude = 87.46598.Can anybody help me .Just tell me where i m wrong.i m using mapwingis activex control.

Reply With Quote

Viewing: Tutorialized ForumsDesktop ProgrammingVisual Basic > Lat/long

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap