Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2006.09.03;
Скачать: [xml.tar.bz2];

Вниз

ищется функция для расчета лунных дней   Найти похожие ветки 

 
другой гость   (2006-07-22 21:11) [0]

Кто сталкивался или знаете, пожалуйста помогите с функцией для расчета лунных дней


 
Kolan ©   (2006-07-22 21:25) [1]

Кажется гдето видел программу на Delphi сделанную.. но как называется ...


 
Пусик ©   (2006-07-22 22:52) [2]


> Kolan ©   (22.07.06 21:25) [1]
> Кажется гдето видел программу на Delphi сделанную.. но как
> называется ...


...и вообще я не осознаю, где нахожусь...


 
KilkennyCat ©   (2006-07-22 23:03) [3]

http://avy.ru/programs/moonday/


 
Kolan ©   (2006-07-22 23:16) [4]


> ...и вообще я не осознаю, где нахожусь...

И вообще шас постараюсь вспомнить... :)


 
Kolan ©   (2006-07-22 23:28) [5]

http://www.yandex.ru/yandsearch?text=%EB%F3%ED%E0+%26%26+delphi&stype=www


 
DrPass ©   (2006-07-23 01:22) [6]

Посмотри в модуле DateUtils :)


 
Kolan ©   (2006-07-23 02:06) [7]

http://www.astronomy.ru/forum/index.php/topic,8725.0.html

Вот а для юлианского календаря ... это есть в DateUtils


 
другой гость   (2006-07-23 15:21) [8]


> KilkennyCat ©   (22.07.06 23:03) [3]
>
> http://avy.ru/programs/moonday/

тут смотрел, почти все поисковики выставляют на первые страницы поиска. но видно из-за патологической лени своей перевести код java в delphi я не могу )


> Kolan ©   (23.07.06 02:06) [7]
>
> http://www.astronomy.ru/forum/index.php/topic,8725.0.html
>

и здесь был, но там функции для расчета фазы луны, но не дней )

всем кто ответил спасибо, пойду посмотрю DateUtils.
буду рад новом предложениям )


 
KilkennyCat ©   (2006-07-23 15:25) [9]

> перевести код java в delphi я не могу

зачэм пэрэвод? там формул ест.


 
другой гость   (2006-07-23 15:36) [10]


> зачэм пэрэвод? там формул ест.


хм такс..я увидел в начале пару масивов, потом чуть ниже и подумал что многовато ) точнее...хм..вобщем пойду пересмотрю


 
KilkennyCat ©   (2006-07-23 16:06) [11]

http://www.turkey-tourism.ru/moon.html


 
другой гость   (2006-07-23 17:55) [12]

Значит.. попробовал переделать http://avy.ru/programs/moonday/ для делфи. Вышло так:

unit moonday;

interface

uses
 SysUtils, Math;

const
 milenium:   Array[1..7]  of extended = (0.0, 13.9, 27.7, 12.1, 25.9, 10.3, 24.2);
 century:    Array[1..10] of extended = (0.0, 4.3, 8.7, 13.0, 17.4, 21.7, 26.0, 0.8, 5.2, 9.5);
 ten:        Array[1..10] of extended = (0.0, 9.3, 18.6, 27.9, 7.6, 16.9, 26.2, 6.0, 15.3, 24.6);
 year:       Array[1..10] of extended = (0.0, 18.6, 7.8, 26.4, 15.5, 4.6, 23.3, 12.4, 1.5, 20.2);
 month_new:  Array[1..12] of extended = (13.4, 11.9, 24.2, 22.6, 22.0, 20.6, 20.0, 18.4, 17.0, 16.6, 15.1, 14.8);
 month_full: Array[1..12] of extended = (28.2, 26.7, 9.5, 7.9, 7.3, 5.8, 5.3, 3.6, 2.2, 1.9, 0.3, 0.0);

function GetDate(ypos1,ypos2,ypos3,ypos4,month,tmoon: integer): extended;
function MoonDayIs(ypos1,ypos2,ypos3,ypos4,month,day,hour: integer): extended;

implementation

function GetDate(ypos1,ypos2,ypos3,ypos4,month,tmoon: integer): extended;
var
 x: extended;
begin
result:=0;
 if ((month=1) or (month=2)) then begin
   ypos4:=ypos4-1;
  if (ypos4<0) then begin
     ypos4:=9;
   ypos3:=ypos3-1;
  end;
  if (ypos3<0) then begin
   ypos3:=9;
   ypos2:=ypos2-1;
  end;
  if (ypos2<0)then begin
   ypos2:=9;
   ypos1:=ypos1-1;
  end;
 end;

 if ((ypos1>=0) and (ypos1<=6)) then result:=result+milenium[ypos1];
 if ((ypos2>=0) and (ypos2<=9)) then result:=result+century[ypos2];
 if ((ypos3>=0) and (ypos3<=9)) then result:=result+ten[ypos3];
 if ((ypos4>=0) and (ypos4<=9)) then result:=result+year[ypos4];

 if (tmoon=1) then
   result:=result+month_new[month-1]
 else
  result:=result+month_full[month-1];

x:=ypos3*10+ypos4;
x:=x/4;
 if (x=1) then result:=result+0.2;
 if (x=2) then result:=result+0.5;
 if (x=3) then result:=result+0.8;

x:=ypos1*10+Math.floor(ypos2);
x:=Math.round(0.75*x-1.625);
result:=result+x;
 if (result>119.1) then result:=result-118.1;
 if (result>89.6)  then result:=result-88.6;
 if (result>60.1)  then result:=result-59.1;
 if (result>30.5)  then result:=result-29.5;

result:=Math.round(result*10)/10;
end;

function MoonDayIs(ypos1,ypos2,ypos3,ypos4,month,day,hour: integer): extended;
var
 nov,dr: extended;
begin
result:=0;
nov:=GetDate(ypos1,ypos2,ypos3,ypos4,month,1);
 if (nov=0) then result;
dr:=Math.floor(day)+(Math.round(hour/24*10)/10);

result:=dr-nov;
 if (result<0) then result:=result+29.5;

result:=Math.floor(result)+1;
end;

end.


собственно ошибки с определением типов для переменных, и до сих пор не нашел аналог "round" в мат.функциях делфи+еще пара мелких ошибок.


 
другой гость   (2006-07-23 17:58) [13]

вот собственно...код какой-никакой появился, давайте в нем попробуем поковыряться?


 
другой гость   (2006-07-23 18:56) [14]

Хм.."round" таки в systems есть..
проект сам билдится с юнитом для расчета, но при


procedure TMain_Form.Button1Click(Sender: TObject);
begin
Label1.Caption:=FloatToStr(MoonDayIs(2,0,0,6,7,23,20));
end;


ошибка выскакивает на

if ((ypos2>=0) and (ypos2<=9)) then result:=result+century[ypos2];


 
KilkennyCat ©   (2006-07-23 19:24) [15]

Открою страшшшшную тайну... массивы "Настоящие Программеры" начинают с нуля...


 
KilkennyCat ©   (2006-07-23 19:39) [16]

Это попытка наспех заменить четыре цифры года одной...
function GetDate(year,month,tmoon: integer): extended;
var
x: extended;
begin
result:=0;
if month < 3 then dec(year);
result := result + mmilenium[trunc(year/1000)];
result := result+century[trunc(frac(year/1000)*10)];
result := result+ten[trunc(frac(year/100)*10)];
result := result+year[trunc(frac(year/10)*10)];

if tmoon = 1 then result := result + month_new[month - 1] else result := result + month_full[month-1];

x := frac(year/100)*25;
if x = 1 then result := result + 0.2;
if x = 2 then result := result + 0.5;
if x = 3 then result := result + 0.8;

x := trunc(year/100);
x := round(0.75 * trunc(year/100)-1.625);
result := result + x;
if result > 119.1 then result := result - 118.1;
if result > 89.6  then result := result - 88.6;
if result > 60.1  then result := result - 59.1;
if result > 30.5  then result := result - 29.5;
result := round(result * 10)/10;
end


 
другой гость   (2006-07-23 21:40) [17]


> Это попытка наспех заменить четыре цифры года одной...

нет, при таком варианте погрешность большая возникает при проверке.

вобщем рабочий код для расчета лунных дней в итоге таков:

unit moonday;

interface

uses
SysUtils, Math;

const
milenium:   Array[0..6]  of extended = (0.0, 13.9, 27.7, 12.1, 25.9, 10.3, 24.2);
century:    Array[0..9] of extended = (0.0, 4.3, 8.7, 13.0, 17.4, 21.7, 26.0, 0.8, 5.2, 9.5);
ten:        Array[0..9] of extended = (0.0, 9.3, 18.6, 27.9, 7.6, 16.9, 26.2, 6.0, 15.3, 24.6);
year:       Array[0..9] of extended = (0.0, 18.6, 7.8, 26.4, 15.5, 4.6, 23.3, 12.4, 1.5, 20.2);
month_new:  Array[0..11] of extended = (13.4, 11.9, 24.2, 22.6, 22.0, 20.6, 20.0, 18.4, 17.0, 16.6, 15.1, 14.8);
month_full: Array[0..11] of extended = (28.2, 26.7, 9.5, 7.9, 7.3, 5.8, 5.3, 3.6, 2.2, 1.9, 0.3, 0.0);

function GetDate(ypos1,ypos2,ypos3,ypos4,month,tmoon: integer): extended;
function MoonDayIs(ypos1,ypos2,ypos3,ypos4,month,day,hour: integer): extended;

implementation

function GetDate(ypos1,ypos2,ypos3,ypos4,month,tmoon: integer): extended;
var
x: extended;
begin
result:=0;
if ((month=1) or (month=2)) then begin
  ypos4:=ypos4-1;
 if (ypos4<0) then begin
    ypos4:=9;
  ypos3:=ypos3-1;
 end;
 if (ypos3<0) then begin
  ypos3:=9;
  ypos2:=ypos2-1;
 end;
 if (ypos2<0)then begin
  ypos2:=9;
  ypos1:=ypos1-1;
 end;
end;

if ((ypos1>=0) and (ypos1<=6)) then result:=result+milenium[ypos1];
if ((ypos2>=0) and (ypos2<=9)) then result:=result+century[ypos2];
if ((ypos3>=0) and (ypos3<=9)) then result:=result+ten[ypos3];
if ((ypos4>=0) and (ypos4<=9)) then result:=result+year[ypos4];

if (tmoon=1) then
  result:=result+month_new[month-1]
else
 result:=result+month_full[month-1];

x:=ypos3*10+ypos4;
x:=x/4;
if (x=1) then result:=result+0.2;
if (x=2) then result:=result+0.5;
if (x=3) then result:=result+0.8;

x:=ypos1*10+Math.floor(ypos2);
x:=Math.round(0.75*x-1.625);
result:=result+x;
if (result>119.1) then result:=result-118.1;
if (result>89.6)  then result:=result-88.6;
if (result>60.1)  then result:=result-59.1;
if (result>30.5)  then result:=result-29.5;

result:=Math.round(result*10)/10;
end;

function MoonDayIs(ypos1,ypos2,ypos3,ypos4,month,day,hour: integer): extended;
var
nov,dr: extended;
begin
result:=0;
nov:=GetDate(ypos1,ypos2,ypos3,ypos4,month,1);
if (nov=0) then result;
dr:=Math.floor(day)+(Math.round(hour/24*10)/10);

result:=dr-nov;
if (result<0) then result:=result+29.5;

result:=Math.floor(result)+1;
end;

end.


 
другой гость   (2006-07-23 21:41) [18]

да забыл добавить...заменить надо все строки "Math.round" на "round"



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2006.09.03;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.51 MB
Время: 0.04 c
11-1132301273
BaryVetaL
2005-11-18 11:07
2006.09.03
TKOLTCPClient и TKOLTCPServer вопрос не для новичков...


15-1154773837
Lancelot
2006-08-05 14:30
2006.09.03
Java для мобильника


2-1155330946
SARbe
2006-08-12 01:15
2006.09.03
Помогите с ComboBox


15-1155305161
wl
2006-08-11 18:06
2006.09.03
Программка для получения реального URL к файлу


15-1154952780
ПЛОВ
2006-08-07 16:13
2006.09.03
Проблемы с сервисом





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский