4 * Vector Routines from CMU vision library.
5 * They are used only for the Voronoi Diagram, not the Delaunay Triagulation.
6 * They are slow because of large call-by-value parameters.
15 public Vec2(float xx, float yy)
19 norm = (float)(x*x + y*y);
37 public void setNorm(float d)
42 /*public String toString()
47 Vec2 circle_center(Vec2 b, Vec2 c)
50 float d1 = vv1.magn();
52 Vec2 vv2 = vv1.times(0.5f);
53 if (d1 < 0.0) /*there is no intersection point, the bisectors coincide. */
56 Vec2 vv3 = b.sub(this);
57 Vec2 vv4 = c.sub(this);
58 float d3 = vv3.cprod(vv4) ;
59 float d2 = (float)(-2.0f * d3) ;
61 float d4 = vv5.dot(vv4);
62 Vec2 vv6 = vv3.cross();
63 Vec2 vv7 = vv6.times((float)(d4/d2));
71 * cprod: forms triple scalar product of [u,v,k], where k = u cross v
72 * (returns the magnitude of u cross v in space)
76 return((float)(x * v.y - y * v.x));
79 /* V2_dot: vector dot product */
83 return((float)(x * v.x + y * v.y));
86 /* V2_times: multiply a vector by a scalar */
90 return (new Vec2((float)(c*x), (float)(c*y)));
93 /* V2_sum, V2_sub: Vector addition and subtraction */
97 return (new Vec2((float)(x + v.x), (float)(y + v.y)));
102 return(new Vec2((float)(x - v.x), (float)(y - v.y)));
105 /* V2_magn: magnitude of vector */
109 return (float) (Math.sqrt((float)(x*x+y*y)));
112 /* returns k X v (cross product). this is a vector perpendicular to v */
116 return(new Vec2((float)y,(float)(-x)));