PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Feedback and Query - 0.6c

Item #1:

When using the search/replace function in the PIDE, a copy of the "replacement text" is inserted at the current cursor location. All substitutions are correctly carried out as expected.

Item #2:

I am using the following code block:

Code:

proc CalcDist(lat1$,lon1$,lat2$,lon2$,dist$,theta$)
local (Pi$,radlat1$,radlon1$,radlat2$,radlon2$);
local (er$,x1$,y1$,z1$,x2$,y2$,z2$,d$);

memo_addline(memo1$,"lat1="+lat1$+" "+
"lon1="+lon1$+" "+
"lat2="+lat2$+" "+
"lon2="+lon2$);

dist$ = 0.0; theta$ = 0.0;
Pi$ = 3.1415926535897932;

radlat1$ = (Pi$*abs(lat1$))/180.0;
radlon1$ = (Pi$*abs(lon1$))/180.0;

if (lat1$ >= 0)
radlat1$ = (Pi$/2.0)-radlat1$;
else
radlat1$ = (Pi$/2.0)+radlat1$;
end;
if (lon1$ < 0) radlon1$ = (Pi$*2)-radlon1$; end;

radlat2$ = (Pi$*abs(lat2$))/180.0;
radlon2$ = (Pi$*abs(lon2$))/180.0;

if (lat2$ >= 0)
radlat2$ = (Pi$/2.0)-radlat2$;
else
radlat2$ = (Pi$/2.0)+radlat2$;
end;
if (lon2$ < 0) radlon2$ = (Pi$*2)-radlon2$; end;

memo_addline(memo1$,"radlat1="+radlat1$+" "+
"radlon1="+radlon1$+" "+
"radlat2="+radlat2$+" "+
"radlon2="+radlon2$);

er$ = 6366.707;

x1$ = er$ * cos(radlon1$)*sin(radlat1$);
y1$ = er$ * sin(radlon1$)*sin(radlat1$);
z1$ = er$ * cos(radlat1$);

x2$ = er$ * cos(radlon2$)*sin(radlat2$);
y2$ = er$ * sin(radlon2$)*sin(radlat2$);
z2$ = er$ * cos(radlat2$);

memo_addline(memo1$,"x1="+x1$+" "+
"y1="+y1$+" "+
"z1="+z1$+" "+
"x2="+x2$+" "+
"x2="+y2$+" "+
"x2="+z2$);

d$ = sqrt(((x1$-x2$)*(x1$-x2$))+((y1$-y2$)*(y1$-y2$))+((z1$-z2$)*(z1$-z2$)));

memo_addline(memo1$,"d="+d$);

theta$ = acos(((er$*er$)+(er$*er$)-(d$*d$))/(2*er$*er$));
dist$ = (theta$*er$);
theta$ = (180.0/Pi$)*theta$;

memo_addline(memo1$,"theta="+theta$+" dist* = "+dist$);
end;


The calling sequence is:

CalcDist(OldLat$,OldLon$,lat$,lon$,&dist$,&theta$);

A trace of teh internal variables during execution shows:

lat1=-27.435718 lon1=153.180938 lat2=-27.519052 lon2=153.097605
radlat1=2.042035 radlon1=2.670354 radlat2=2.042035 radlon2=2.670354
x1=-5054.481740 y1=2575.387081 z1=-2890.424493 x2=-5054.481740 x2=2575.387081 x2=-2890.424493
d=0
theta=0

NOTE:

while lat1 DOES NOT EQUAL lat2 the calculated values for radlat1 and radlat2 ARE EQUAL.

Any clues as to whats going wrong?
mervjoyce · 12 Jul 2004, 23:47 UTC — ABS function behaviour
I have applied a few more "trace" prints to the code block in my previous post.

It would appear that the "abs" function returns an integer result -- not a real. In my example :

lat1$ = -27.435828 //from applied calculation
abs(lat1$) => 27

Is this a bug, or is my definition/handling of the variables incorrect!

Help!
Hi,

It is a bug. I will fix it, thanks for the report.

Regards,
Kornalius
Hi,

1. Can you give me more details as to what is happening, I will fix this bug tomorrow.

2. The abs() function has been fixed to work with doubles now.

Regards,
Kornalius
mervjoyce · 20 Jul 2004, 05:22 UTC — "Replace" functionality in PIDE
Hi Kornalius,

When I use the "search and replace" function in the PIDE (to perform multiple replacements) I find that an additional copy of the replacement text is inserted at the initial cursor location (eg: from where the search begins).

This is not a major drama .. just reporting it for completeness.
Hi,

I just fixed this problem. Thanx for the report.

Regards,
Kornalius