Comments
On satoshiideleted, 2 years ago
0
you mean like USACO?
- -!
I think it will lose a lot of fun of algorithm competition.
but this still a good idea.
Every man has his hobbyhorse.
Satyr!
May be I pressed but it didn't work,so I pressed several times.
- -!
I use Firefox。

P.S. I'm not a girl.- -!
- -!
Why there are so many reply by me.

P.S. wow,your photo is a cat.My ID is a cat too(cat=mao).
I think the standard libraries about ptLineDist is not good;

this is the ptLineDist source code;


public static double
ptLineDistSq (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
 
X2 -= X1;
     Y2 -= Y1;
 
PX -= X1;
     PY -= Y1;
     double dotprod = PX * X2 + PY * Y2;
   
double projlenSq = dotprod * dotprod / (X2 * X2 + Y2 * Y2);
   
double lenSq = PX * PX + PY * PY - projlenSq;
   
if (lenSq < 0) {
         
lenSq = 0;
    }
   
return lenSq;
}

public static double ptLineDist (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
    return
return Math.sqrt(ptLineDistSq(X1, Y1, X2, Y2, PX, PY));
}

in the method
ptLineDistSq java stander use dot-product to calculate the dist.
and use dot*dot this maybe as larger as x^4,but
(X2 * X2 + Y2 * Y2) is x^2;
so the result
projlenSq could be make a flat error,and make lenSq could be very small,even to zero.

you can try write a new method use cross-product,then you will find it come up with the correct answer:
    public static double pointToLineDist(Point p,Point A,Point B)
    {
        return Math.abs(p.sub(A).cross(B.sub(A))/B.sub(A).len());
    }


I think the standard libraries about ptLineDist is not good;

this is the ptLineDist source code;


public static double
ptLineDistSq (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
 
X2 -= X1;
     Y2 -= Y1;
 
PX -= X1;
     PY -= Y1;
     double dotprod = PX * X2 + PY * Y2;
   
double projlenSq = dotprod * dotprod / (X2 * X2 + Y2 * Y2);
   
double lenSq = PX * PX + PY * PY - projlenSq;
   
if (lenSq < 0) {
         
lenSq = 0;
    }
   
return lenSq;
}

public static double ptLineDist (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
    return
return Math.sqrt(ptLineDistSq(X1, Y1, X2, Y2, PX, PY));
}

in the method
ptLineDistSq java stander use dot-product to calculate the dist.
and use dot*dot this maybe as larger as x^4,but
(X2 * X2 + Y2 * Y2) is x^2;
so the result
projlenSq could be make a flat error,and make lenSq could be very small,even to zero.

you can try write a new method use cross-product,then you will find it come up with the correct answer:
    public static double pointToLineDist(Point p,Point A,Point B)
    {
        return Math.abs(p.sub(A).cross(B.sub(A))/B.sub(A).len());
    }


I think the standard libraries about ptLineDist is not good;

this is the ptLineDist source code;


public static double
ptLineDistSq (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
 
X2 -= X1;
     Y2 -= Y1;
 
PX -= X1;
     PY -= Y1;
     double dotprod = PX * X2 + PY * Y2;
   
double projlenSq = dotprod * dotprod / (X2 * X2 + Y2 * Y2);
   
double lenSq = PX * PX + PY * PY - projlenSq;
   
if (lenSq < 0) {
         
lenSq = 0;
    }
   
return lenSq;
}

public static double ptLineDist (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
    return
return Math.sqrt(ptLineDistSq(X1, Y1, X2, Y2, PX, PY));
}

in the method
ptLineDistSq java stander use dot-product to calculate the dist.
and use dot*dot this maybe as larger as x^4,but
(X2 * X2 + Y2 * Y2) is x^2;
so the result
projlenSq could be make a flat error,and make lenSq could be very small,even to zero.

you can try write a new method use cross-product,then you will find it come up with the correct answer:
    public static double pointToLineDist(Point p,Point A,Point B)
    {
        return Math.abs(p.sub(A).cross(B.sub(A))/B.sub(A).len());
    }


I think the standard libraries about ptLineDist is not good;

this is the ptLineDist source code;


public static double
ptLineDistSq (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
 
X2 -= X1;
     Y2 -= Y1;
 
PX -= X1;
     PY -= Y1;
     double dotprod = PX * X2 + PY * Y2;
   
double projlenSq = dotprod * dotprod / (X2 * X2 + Y2 * Y2);
   
double lenSq = PX * PX + PY * PY - projlenSq;
   
if (lenSq < 0) {
         
lenSq = 0;
    }
   
return lenSq;
}

public static double ptLineDist (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
    return
return Math.sqrt(ptLineDistSq(X1, Y1, X2, Y2, PX, PY));
}

in the method
ptLineDistSq java stander use dot-product to calculate the dist.
and use dot*dot this maybe as larger as x^4,but
(X2 * X2 + Y2 * Y2) is x^2;
so the result
projlenSq could be make a flat error,and make lenSq could be very small,even to zero.

you can try write a new method use cross-product,then you will find it come up with the correct answer:
    public static double pointToLineDist(Point p,Point A,Point B)
    {
        return Math.abs(p.sub(A).cross(B.sub(A))/B.sub(A).len());
    }


I think the standard libraries about ptLineDist is not good;

this is the ptLineDist source code;


public static double
ptLineDistSq (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
 
X2 -= X1;
     Y2 -= Y1;
 
PX -= X1;
     PY -= Y1;
     double dotprod = PX * X2 + PY * Y2;
   
double projlenSq = dotprod * dotprod / (X2 * X2 + Y2 * Y2);
   
double lenSq = PX * PX + PY * PY - projlenSq;
   
if (lenSq < 0) {
         
lenSq = 0;
    }
   
return lenSq;
}

public static double ptLineDist (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
    return
return Math.sqrt(ptLineDistSq(X1, Y1, X2, Y2, PX, PY));
}

in the method
ptLineDistSq java stander use dot-product to calculate the dist.
and use dot*dot this maybe as larger as x^4,but
(X2 * X2 + Y2 * Y2) is x^2;
so the result
projlenSq could be make a flat error,and make lenSq could be very small,even to zero.

you can try write a new method use cross-product,then you will find it come up with the correct answer:
    public static double pointToLineDist(Point p,Point A,Point B)
    {
        return Math.abs(p.sub(A).cross(B.sub(A))/B.sub(A).len());
    }


I think the standard libraries about ptLineDist is not good;

this is the ptLineDist source code;


public static double
ptLineDistSq (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
 
X2 -= X1;
     Y2 -= Y1;
 
PX -= X1;
     PY -= Y1;
     double dotprod = PX * X2 + PY * Y2;
   
double projlenSq = dotprod * dotprod / (X2 * X2 + Y2 * Y2);
   
double lenSq = PX * PX + PY * PY - projlenSq;
   
if (lenSq < 0) {
         
lenSq = 0;
    }
   
return lenSq;
}

public static double ptLineDist (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
    return
return Math.sqrt(ptLineDistSq(X1, Y1, X2, Y2, PX, PY));
}

in the method
ptLineDistSq java stander use dot-product to calculate the dist.
and use dot*dot this maybe as larger as x^4,but
(X2 * X2 + Y2 * Y2) is x^2;
so the result
projlenSq could be make a flat error,and make lenSq could be very small,even to zero.

you can try write a new method use cross-product,then you will find it come up with the correct answer:
    public static double pointToLineDist(Point p,Point A,Point B)
    {
        return Math.abs(p.sub(A).cross(B.sub(A))/B.sub(A).len());
    }


I think the standard libraries about ptLineDist is not good;

this is the ptLineDist source code;


public static double
ptLineDistSq (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
 
X2 -= X1;
     Y2 -= Y1;
 
PX -= X1;
     PY -= Y1;
     double dotprod = PX * X2 + PY * Y2;
   
double projlenSq = dotprod * dotprod / (X2 * X2 + Y2 * Y2);
   
double lenSq = PX * PX + PY * PY - projlenSq;
   
if (lenSq < 0) {
         
lenSq = 0;
    }
   
return lenSq;
}

public static double ptLineDist (double X1, double Y1,
                      double X2, double Y2,
                      double PX, double PY) {
    return
return Math.sqrt(ptLineDistSq(X1, Y1, X2, Y2, PX, PY));
}

in the method
ptLineDistSq java stander use dot-product to calculate the dist.
and use dot*dot this maybe as larger as x^4,but
(X2 * X2 + Y2 * Y2) is x^2;
so the result
projlenSq could be make a flat error,and make lenSq could be very small,even to zero.

you can try write a new method use cross-product,then you will find it come up with the correct answer:
    public static double pointToLineDist(Point p,Point A,Point B)
    {
        return Math.abs(p.sub(A).cross(B.sub(A))/B.sub(A).len());
    }


+2
I think this website would better if it own a forum.
On rng_58Self Introduction, 2 years ago
0
I read you ID in topcoder.
You are a red man.
I want to study abroad in your school.
Can you introduce me?
aha.
It just a joke,but I really dream to study abroad in your school.
0
No pain,No gain!
Go your own way,let others talk!
Cheer up!
Code our life.