Ejemplo n.º 1
0
//Projection of V onto this vector
Vector Vector::Project(Vector v)
{
	Vector p(X,Y);
	p.Divide(GetMagnitude());
	p.Multiply(DotProduct(v) / GetMagnitude());
	
	return p;
}
Ejemplo n.º 2
0
int main() {
  std::vector<cv::Mat> images = CreateTestMats();
  cv::Mat uflow, cflow, flow;
  cv::calcOpticalFlowFarneback(images[0], images[1], uflow, 0.5, 3, 5, 3, 5,
                               1.1, 0);
  auto optical_flow = oflow::utils::GetOpticalFlow(uflow);

  //  cv::cvtColor(images[0], cflow, cv::COLOR_GRAY2BGR);
  //  uflow.copyTo(flow);
  //  cv::drawOptFlowMap(flow, cflow, 11, 1.5, cv::Scalar(0, 255, 0));

  cv::namedWindow("Magnitude", 1);
  imshow("Magnitude", ResizeImage(optical_flow.GetMagnitude()));

  cv::namedWindow("Vx", 1);
  imshow("Vx", ResizeImage(optical_flow.GetVx()));

  cv::namedWindow("Vy", 1);
  imshow("Vy", ResizeImage(optical_flow.GetVy()));

  cv::namedWindow("Orientation", 1);
  imshow("Orientation", ResizeImage(optical_flow.GetOrientation()));

  std::cout << "Orientation: " << std::endl << optical_flow.GetOrientation()
            << std::endl;
  cv::waitKey(0);
}
void NormalizeFeatureVector(vector<float> &listValue)
{
	float vectorLength = GetMagnitude(listValue);
	for (int i = 0; i < (int)listValue.size(); i++)
	{
		listValue[i] /= (float)vectorLength;
	}
}
Ejemplo n.º 4
0
//+===================================+//
//	Normalise the Vec2
//  returns result as a Vec2	
//+===================================+//
Vec2 Vec2::NormaliseVec2()
{
	float fMag = GetMagnitude();
	if( fMag != 0.f )
	{		
		return Vec2( ( m_fX / fMag ), ( m_fY / fMag ) );
	}
	return Vec2( 0, 0 );
}
Ejemplo n.º 5
0
//------------------------------------------------------------------------------
//  Rvector3 GetUnitVector() const
//------------------------------------------------------------------------------
Rvector3 Rvector3::GetUnitVector() const
{
   Real mag = GetMagnitude();

   if (GmatMathUtil::IsZero(mag))
      throw ZeroVector(" from Rvector3::GetUnitVector()\n");
   
   return Rvector3(elementD[0]/mag, elementD[1]/mag, elementD[2]/mag);
}
Ejemplo n.º 6
0
 Vector4D Vector4D::Normalized()
 {
   float magnitude = GetMagnitude();
   BML::Vector4D result;
   result.m_x = m_x / magnitude;
   result.m_y = m_y / magnitude;
   result.m_z = m_z / magnitude;
   result.m_w = m_w / magnitude;
   return result;
 }
Ejemplo n.º 7
0
  void Vector4D::Normalize()
  {
    //Normalize the vector
    float magnitude = GetMagnitude();

    m_x /= magnitude;
    m_y /= magnitude;
    m_z /= magnitude;
    m_w /= magnitude;
  }
Ejemplo n.º 8
0
	void Vector2::Normalize(float length)
	{
		float mag = GetMagnitude();
		x /= mag;
		y /= mag;
		if (length != 1.0f)
		{
			x *= length;
			y *= length;
		}
	}
void ZFXQuat::Normalize()
{
	float m = GetMagnitude();
	if (m != 0)
	{
		x /= m; 
		y /= m; 
		z /= m; 
		w /= m;
	}
}
Ejemplo n.º 10
0
//------------------------------------------------------------------------------
//  const Rvector3& Normalize()
//------------------------------------------------------------------------------
const Rvector3& Rvector3::Normalize()
{
   Real mag = GetMagnitude();
   
   if (GmatMathUtil::IsZero(mag))
      throw ZeroVector(" from Rvector3::Normalize()\n");
   
   elementD[0] /= mag;
   elementD[1] /= mag;
   elementD[2] /= mag;
   return *this;
}
Ejemplo n.º 11
0
void CollisionSystem::SlowEntity(std::shared_ptr<Entity> slowingEntity,
    std::shared_ptr<Entity> movingEntity)
{
    auto slowingComponent = std::static_pointer_cast<SlowingComponent>(Engine::GetInstance().GetSingleComponentOfClass(slowingEntity, "SlowingComponent"));
    auto particleComponent = std::static_pointer_cast<ParticleComponent>(Engine::GetInstance().GetSingleComponentOfClass(movingEntity, "ParticleComponent"));

    float magnitude = slowingComponent->GetMagnitude();
    Vector velocity = particleComponent->GetVelocity();

    velocity *= magnitude;

    particleComponent->SetVelocity(velocity);
}
Ejemplo n.º 12
0
XBOX_AxisState XBOX360_Controller::Get_AxisState()
{
    XBOX_AxisState retval;
    retval.Raw_LX = ((GetRawAxis(XBOX360_LEFT_X)*GetRawAxis(XBOX360_LEFT_X)) > LSxDZ ) ? GetRawAxis(XBOX360_LEFT_X) : 0.0;
    retval.Raw_LY = ((GetRawAxis(XBOX360_LEFT_Y)*GetRawAxis(XBOX360_LEFT_Y)) > LSyDZ ) ? GetRawAxis(XBOX360_LEFT_Y) : 0.0;
    retval.Raw_RX = ((GetRawAxis(XBOX360_RIGHT_X)*GetRawAxis(XBOX360_RIGHT_X))> RSxDZ) ? GetRawAxis(XBOX360_RIGHT_X) : 0.0;
    retval.Raw_RY = ((GetRawAxis(XBOX360_RIGHT_Y)*GetRawAxis(XBOX360_RIGHT_Y))> RSyDZ) ? GetRawAxis(XBOX360_RIGHT_Y) : 0.0;
    retval.RTrigger = (GetRawAxis(XBOX360_RTRIGGER) > RtrigDZ) ? GetRawAxis(XBOX360_RTRIGGER) : 0.0;
    retval.LTrigger = (GetRawAxis(XBOX360_LTRIGGER) > LtrigDZ) ? GetRawAxis(XBOX360_LTRIGGER) : 0.0;
    retval.Magnitude = GetMagnitude();
    retval.RelativeHeading = GetDirectionDegrees();
    return retval;
}
Ejemplo n.º 13
0
void CAudio::GetPowerSpectrum(double* ps,const double* data,unsigned long size)
{
	ENTER_SECTION(this);

	// Just lerp-copy the array
	for(unsigned long x = 0; x < size; ++x)
	{
		// Get magnitude of this band
		double mag = GetMagnitude(-data[x],1.35,2.0,x,size);

		// We put - so we get bands jumpung up instead of down
		ps[x] = -max(140.0 * mag,0.0);
	}
}
Ejemplo n.º 14
0
 void Vector2d::Normalize() {
     (*this) /= GetMagnitude();
 }
Ejemplo n.º 15
0
	void Vector2::Normalize()
	{
		float mag = GetMagnitude();
		x /= mag;
		y /= mag;
	}
Ejemplo n.º 16
0
	Vector2 Vector2::GetNormalized()
	{
		float mag = GetMagnitude();
		return Vector2(x / mag, y / mag);
	}
Ejemplo n.º 17
0
/** @details Sets the vector's angle while preserving its magnitude.  The new x is calculated based
 *  off the cosine function and the new y is based off the sine function.  The existing magnitude
 *  is calculated via @ref GetMagnitude and applied back to the vector after the x and y have been
 *  calculated.
 *  @warning This method uses sqrt() which can be slow!
 *  @param angle The new angle (in radians) for the vector.
 */
_JATTA_EXPORT void Jatta::Vector2::SetAngle(Float32 angle)
{
    Float32 magnitude = GetMagnitude();
    x = Math::Cos(angle) * magnitude;
    y = Math::Sin(angle) * magnitude;
}
Ejemplo n.º 18
0
/** @warning This method uses sqrt() which can be slow!
 */
_JATTA_EXPORT Jatta::Boolean Jatta::Vector2::IsNormalized(Float32 epsilon) const
{
    return Math::InEpsilon(GetMagnitude(), 1, epsilon);
}
Ejemplo n.º 19
0
double Vector3D::GetAngle(Vector3D v2)
{
    double angle = acos(DotProduct(v2) / (GetMagnitude() * v2.GetMagnitude()));
    return isnan(angle) ? 0.0 : angle;
}
Ejemplo n.º 20
0
	Vector2 Vector2::GetNormalized(float length)
	{
		float mag = GetMagnitude();
		return Vector2((x / mag) * length, (y / mag) * length);
	}
Ejemplo n.º 21
0
//Return unit vector of this
Vector Vector::UnitVector()
{
	Vector p(X,Y);
	p.Divide(GetMagnitude());
	return p;
}
Ejemplo n.º 22
0
/** @warning This method uses sqrt() which can be slow!
 */
_JATTA_EXPORT void Jatta::Vector2::Normalize()
{
    Float32 inverseMagnitude = 1.0f / GetMagnitude();
    x *= inverseMagnitude;
    y *= inverseMagnitude;
}
Ejemplo n.º 23
0
//------------------------------------------------------------------------------
void Rvector3::ComputeLongitudeLatitude(Real &lon, Real &lat)
{
   lon = GmatMathUtil::ATan2(elementD[1], elementD[0]);
   lat = GmatMathUtil::ASin(elementD[2] / GetMagnitude());
}
Ejemplo n.º 24
0
Vector3D Vector3D::ToUnitVector()
{
    double magnitude = GetMagnitude();
    return this->Scale(1 / magnitude);
}