Главная страница | назад





Article #17915: Calculating a point using angles and distance

 Question and Answer Database
FAQ2915D.txt Calculating a point using angles and distance
Category :Object Pascal
Platform :All
Product :All 32 bit
Question:
How do I calculate the x and y coordinates of a point that is
at some distance and angle away?
Answer:
The following example shows how to convert a polar coordinate to a
rectangular coordinate:
procedure TForm1.Button1Click(Sender: TObject);
var
Angle : Double;
x : Double;
y : Double;
Distance : Double;
Radians : Double;
begin
Distance := 100;
Angle := 270;
Radians := Angle * DegToRad;
x := Round(Distance * Cos(Radians));
y := Round(Distance * Sin(Radians));
ShowMessage(FloatToStr(x) + ' ' + FloatToStr(y));
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99