whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

53 Visitors Online


 
...Determine the incenter of 3 pionts?
Autor: Arash Partow
Homepage: http://www.partow.net
[ Print tip ]  

Tip Rating (13):  
     


procedure Incenter(const x1, y1, x2, y2, x3, y3: Double; out Px, Py: Double);
var
  
Perim: Double;
  Side12: Double;
  Side23: Double;
  Side31: Double;
begin
  
Side12 := Distance(x1, y1, x2, y2);
  Side23 := Distance(x2, y2, x3, y3);
  Side31 := Distance(x3, y3, x1, y1);

  (* Using Heron's S=UR *)
  
Perim := 1.0 / (Side12 + Side23 + Side31);
  Px    := (Side23 * x1 + Side31 * x2 + Side12 * x3) * Perim;
  Py    := (Side23 * y1 + Side31 * y2 + Side12 * y3) * Perim;
end;
(* End of Incenter *)


function Distance(const x1, y1, x2, y2: Double): Double;
var
  
dx: Double;
  dy: Double;
begin
  
dx     := x2 - x1;
  dy     := y2 - y1;
  Result := Sqrt(dx * dx + dy * dy);
end;
(* End of Distance *)


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners