示例#1
0
void R3Matrix:: 
Scale(const R2Vector& scale)
{
    // Scale matrix
    XScale(scale.X());
    YScale(scale.Y());
}
示例#2
0
R2Vector 
operator/(const R2Vector& vector, double a)
{
  assert(a != 0);
  return R2Vector(vector.X() / a, 
                  vector.Y() / a);
}
示例#3
0
void R3Matrix:: 
Translate(const R2Vector& offset)
{
    // Translate matrix
    XTranslate(offset.X());
    YTranslate(offset.Y());
}
示例#4
0
R2Vector
operator*(const R3Matrix& a, const R2Vector& v)
{
    // Multiply matrix by vector
    RNCoord x = a.m[0][0] * v.X() + a.m[0][1] * v.Y();
    RNCoord y = a.m[1][0] * v.X() + a.m[1][1] * v.Y();
    return R2Vector(x, y);
}
示例#5
0
RNLength R2Distance(const R2Point& point, const R2Ray& ray)
{
    // Check if start point is closest
    R2Vector v = point - ray.Start();
    RNScalar dir = v.Dot(ray.Vector());
    if (RNIsNegative(dir)) return v.Length();

    // Return distance from point to ray line
    return R2Distance(point, ray.Line());
}
示例#6
0
R2Diad::
R2Diad(const R2Vector& xaxis, const R2Vector& yaxis)
{
    // Just checking ...
    assert(xaxis.IsNormalized());
    assert(yaxis.IsNormalized());
    assert(R2Perpendicular(xaxis, yaxis));

    // Assign axes
    axis[0] = xaxis;
    axis[1] = yaxis;
}
示例#7
0
void R2Vector::Project(const R2Vector& vector)
{
    // Project onto another vector    
    double dot = Dot(vector);
    double length = vector.Length();
    if (length != 0) dot /= (length * length);
    *this = vector * dot;
}
示例#8
0
R2Point 
operator-(const R2Point& point, const R2Vector& vector)
{
    return R2Point(point.X() - vector.X(), 
		   point.Y() - vector.Y());
}
示例#9
0
R2Halfspace::
R2Halfspace(const R2Point& point, const R2Vector& normal)
    : line(point, R2Vector(-normal.Y(), normal.X()))
{
}
示例#10
0
double operator%(const R2Vector& vector1, const R2Vector& vector2)
{
    // Return cross product
    return vector1.X()*vector2.Y() - vector1.Y()*vector2.X();
}
示例#11
0
R2Vector operator*(const R2Vector& vector, double a)
{
    return R2Vector(vector.X() * a, 
            vector.Y() * a);
}
示例#12
0
R2Vector operator-(const R2Vector& vector)
{
    return R2Vector(-vector.X(), 
            -vector.Y());
}
示例#13
0
RNLength R2Distance(const R2Point& point1, const R2Point& point2)
{
    // Return length of vector between points
    R2Vector v = point1 - point2;
    return v.Length();
}
示例#14
0
RNLength R2SquaredDistance(const R2Point& point1, const R2Point& point2)
{
    // Return squared length of vector between points
    R2Vector v = point1 - point2;
    return v.Dot(v);
}