Finding the maximum area of three XY points in an array of XY points

I'm trying to find the maximum area using three XY points in an array of XY points in the form of (X,Y).

I'm currently getting the error called object type 'double' is not a function or function pointer where the area function is called and I'm not sure why. Also, I have no idea if this function is even close to being right, I'm just messing around at this point. Thanks for the help!

double area( const Point & a, const Point & b, const Point & c){

    double side1 = a.distance(b);
    double side2 = b.distance(c);
    double side3 = c.distance(a);
    double s = (side1 + side2 + side3 / 2.0);

    return sqrt(s * (s - side1) * (s - side2) * (s - side3));
}

double maxArea( const Point a[], unsigned elements ){

        double area = 0;
    double tempArea = 0;

    for (unsigned i = 0 ; i < elements; i++)
        for (unsigned n = 0; n < elements; n++) 
            for (unsigned p = 0; p < elements; p++) {
                tempArea = area(a[i],a[n],a[p]); //error here
                if(tempArea > area){
                    area = tempArea; 
                }
            }
    return area; 
}

Answers


double area = 0;

tempArea = area(a[i],a[n],a[p]); 
         ///^^^

has the same name as your function area. try to use a different variable name, for example: maxArea. Meanwhile, better to change your function name to start with verb, for example: getArea or computeArea.

One more point:

 double s = (side1 + side2 + side3 / 2.0);

should be

 double s = (side1 + side2 + side3) / 2.0;

Need Your Help

LINQ Query-Select records where all the children meet a condition

c# linq

I have a One to Many relationship. I want to select all records from the parent table where it's children all meet a specific condition. If one of the children fails then that record is not returned.

AdvancedDataGrid hell: data on grouping rows

flex actionscript-3 grouping hierarchical-data advanceddatagrid

I need a hierarchical grid that shows data in columns for the parent rows as well as the child rows.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.