Vector Vector::DotProduct(const Vector &v)
{
	double k1 = (y * v.z) - (z * v.y);
	double k2 = (z * v.x) - (x * v.z);
	double k3 = (x * v.y) - (y * v.x);

	return Vector(NumBounds(k1), NumBounds(k2), NumBounds(k3));
}
double Vector::operator[](unsigned int index) const
{
	if (index == 0)
		return NumBounds(x); else
	if (index == 1)
		return NumBounds(y); else
	if (index == 2)
		return NumBounds(z); else
			return 0;
};
Beispiel #3
0
void AstTypeParameter::Unparse(Ostream& os, LexStream* lex_stream)
{
    if (debug_unparse)
        os << "/*AstTypeParameter:#" << id << "*/";
    os << lex_stream -> NameString(identifier_token);
    if (NumBounds())
    {
        os << " extends ";
        Bound(0) -> Unparse(os, lex_stream);
    }
    for (unsigned i = 1; i < NumBounds(); i++)
    {
        os << " & ";
        Bound(i) -> Unparse(os, lex_stream);
    }
    if (debug_unparse)
        os << "/*:AstTypeParameter#" << id << "*/";
}
double Vector::Length() const
{
	return NumBounds(sqrt((x * x) + (y * y) + (z * z)));
};
void Vector::Set(double _x, double _y, double _z)
{
	x = NumBounds(_x); y = NumBounds(_y); z = NumBounds(_z);
};
void Vector::SetZ(double s)
{
	z = NumBounds(s);
};
void Vector::operator*=(double s)
{
	x *= NumBounds(s); y *= NumBounds(s); z *= NumBounds(s);
};
void Vector::operator+=(double s)
{
	x += NumBounds(s); y += NumBounds(s); z += NumBounds(s);
};
void Vector::operator=(const Vector& v)
{
	x = NumBounds(v.x); y = NumBounds(v.y); z = NumBounds(v.z);
};
double Vector::GetY() const
{
	return NumBounds(y);
};
double Vector::GetX() const
{
	return NumBounds(x);
};
Vector Vector::operator/(double s)
{
	s = NumBounds(s);
	return Vector(x / s, y / s, z / s);
};
double Vector::operator*(const Vector &v)
{
	return NumBounds((x * v.x) + (y * v.y) + (z * v.z));
};
Vector::Vector(double _x, double _y, double _z)
{
	x = NumBounds(_x); y = NumBounds(_y); z = NumBounds(_z);
};
void Vector::operator/=(double s)
{
	x /= NumBounds(s); y /= NumBounds(s); z /= NumBounds(s);
};
Vector::Vector(const Vector &v)
{
	x = NumBounds(v.x); y = NumBounds(v.y); z = NumBounds(v.z);
};
bool Vector::operator==(const Vector &v)
{
	if (NumBounds(x) == NumBounds(v.x) && NumBounds(y) == NumBounds(v.y) && NumBounds(z) == NumBounds(v.z))
		return true; else
			return false;
};
double Vector::GetZ() const
{
	return NumBounds(z);
};
void Vector::operator+=(const Vector &v)
{
	x += NumBounds(v.x); y += NumBounds(v.y); z += NumBounds(v.z);
};
void Vector::SetX(double s)
{
	x = NumBounds(s);
};
void Vector::operator-=(const Vector &v)
{
	x -= NumBounds(v.x); y -= NumBounds(v.y); z -= NumBounds(v.z);
};
void Vector::SetY(double s)
{
	y = NumBounds(s);
};