Example #1
0
Vector4& Vector4::Normalize(void)
{
	float mag = ComputeMagnitude();
	x /= mag;
	y /= mag;
	z /= mag;
	w /= mag;
	return *this;
}
/**
   sets the vector to new components.
  */
void vectorNode::SetComponents(double p0, double p1, double p2)
{
   pv_p[0] = p0;
   pv_p[1] = p1;
   pv_p[2] = p2;

// recompute magnitute and nullity
   ComputeMagnitude();
   pv_is_null = isNull();
}
Example #3
0
/**
   sets the vector to new components.
  */
void aVector::SetVector(double p0, double p1, double p2)
{
   pv_p[0] = p0;
   pv_p[1] = p1;
   pv_p[2] = p2;

// recompute magnitute and nullity
   ComputeMagnitude();
   pv_is_null = isNullVector();
}
/**
   this constructor builds the vector with the values passed
   (the components in the stated order)
  */
vectorNode::vectorNode(double p0, double p1, double p2)
   : pv_size(3)
{
   pv_p    = new double[pv_size];
   pv_p[0] = p0;
   pv_p[1] = p1;
   pv_p[2] = p2;

   ComputeMagnitude();    // compute and store vector mag

   pv_is_null   = isNull();
}
/**
   this defines a default behaviour. the vector is set
   to a unit vector with components (1,0,0).
   note that the size is always 3.
  */
vectorNode::vectorNode()
   : pv_size(3)
{
   pv_p    = new double[pv_size];
   pv_p[0] = 1.0;                 // set default values
   pv_p[1] = 0.0;
   pv_p[2] = 0.0;

   ComputeMagnitude();           // compute and store vector mag

   pv_is_null   = false;
}
Example #6
0
/**
   set the i-th component of the vector
  */
void aVector::SetAComp(int i, double p_val)
{
#ifdef CHECKBOUNDS_ON
   CheckBounds(i);
#endif

   pv_p[i] = p_val;

// recompute magnitude and nullity
   ComputeMagnitude();
   pv_is_null = isNullVector();
}
Example #7
0
/**
   this defines a default behaviour. the vector is set
   to a unit vector with components (1,0,0).
   note that the size is always 3.
  */
aVector::aVector()
   : pv_size(3)
{
   pv_p    = new double[pv_size]; // allocate space
   pv_p[0] = 1.0;                 // set default values
   pv_p[1] = 0.0;
   pv_p[2] = 0.0;

   ComputeMagnitude();           // compute and store vector mag
   pv_bln_true  = TRUE;
   pv_bln_false = FALSE;
   pv_is_null   = pv_bln_false;
}
Example #8
0
/**
   this constructor builds the vector with the values passed
   (the components in the stated order)
  */
aVector::aVector(double p0, double p1, double p2)
   : pv_size(3)
{
   pv_p    = new double[pv_size];  // allocate space
   pv_p[0] = p0;
   pv_p[1] = p1;
   pv_p[2] = p2;

   ComputeMagnitude();    // compute and store vector mag

   pv_is_null   = isNullVector();

   pv_bln_true  = TRUE;
   pv_bln_false = FALSE;
}