void Line::SetPosition(const Vector2D& position) { this->SetPointOne(GetPointOne().GetX() - position.GetX(), GetPointOne().GetY() - -position.GetY()); this->SetPointTwo(GetPointTwo().GetX() - position.GetX(), GetPointTwo().GetY() - -position.GetY()); CalculateLengthSquared(); CalculateSlope(); Shape::SetPosition(a2de::Vector2D(_extent_one.GetX() + _extent_two.GetX() / 2.0, _extent_one.GetY() + _extent_two.GetY() / 2.0)); }
/* Changes that are made when a player kicks a ball. */ void Game::KickEvent(int team){ if (state == HOLD && team == m_team){ state = WALK; CalculateSlope(); m_team_last = m_team; m_player_last = m_player; } }
float ObjectManip::Armspeed(float position, float target) { float lowTarget = target - 2; float highTarget = target + 2; float speed; if (position < lowTarget) speed = CalculateSlope(0, 0.6f, target, 0.4f) * position + 0.6f; else if (position > highTarget) { float slope = CalculateSlope(target, -0.4f, SETF, -0.6f); float intercept = -0.6f - slope * SETF; speed = slope * position + intercept; } else speed = 0; return -speed; }
bool LineSegment::ContainsPoint(const Point3D& point) const { Rect rect(p1, p2); if (rect.ContainsPoint(point) == true) { Float slope = CalculateSlope(p1, point); return (Smooth(slope) == Smooth(GetSlope())); } return false; }
Line& Line::operator=(const Line& rhs) { if(this == &rhs) return *this; Shape::operator=(rhs); this->_extent_one = rhs._extent_one; this->_extent_two = rhs._extent_two; CalculateLengthSquared(); CalculateSlope(); Shape::SetPosition(a2de::Vector2D(_extent_one.GetX() + _extent_two.GetX() / 2.0, _extent_one.GetY() + _extent_two.GetY() / 2.0)); return *this; }
Line::Line(const Line& line) : Shape(line), _extent_one(line.GetPointOne()), _extent_two(line.GetPointTwo()), _slope(), _length_squared(0.0) { _type = Shape::SHAPETYPE_LINE; CalculateLengthSquared(); CalculateSlope(); Shape::SetPosition(a2de::Vector2D(_extent_one.GetX() + _extent_two.GetX() / 2.0, _extent_one.GetY() + _extent_two.GetY() / 2.0)); }
Line::Line(const Point& one, const Point& two, const a2de::Color& color) : Shape(0.0, 0.0, 0, 0, color, false), _extent_one(one.GetPosition()), _extent_two(two.GetPosition()), _slope(), _length_squared(0.0) { _type = Shape::SHAPETYPE_LINE; CalculateLengthSquared(); CalculateSlope(); Shape::SetPosition(a2de::Vector2D(_extent_one.GetX() + _extent_two.GetX() / 2.0, _extent_one.GetY() + _extent_two.GetY() / 2.0)); }
Line::Line(double x1, double y1, double x2, double y2, const a2de::Color& color) : Shape(0.0, 0.0, 0, 0, color, false), _extent_one(a2de::Vector2D(x1, y1)), _extent_two(a2de::Vector2D(x2, y2)), _slope(), _length_squared(0.0) { _type = Shape::SHAPETYPE_LINE; CalculateLengthSquared(); CalculateSlope(); Shape::SetPosition(a2de::Vector2D(_extent_one.GetX() + _extent_two.GetX() / 2.0, _extent_one.GetY() + _extent_two.GetY() / 2.0)); }
A2DE_BEGIN Line::Line() : Shape(), _extent_one(a2de::Vector2D()), _extent_two(a2de::Vector2D()), _slope(), _length_squared(0.0) { _type = Shape::SHAPETYPE_LINE; CalculateLengthSquared(); CalculateSlope(); Shape::SetPosition(a2de::Vector2D(_extent_one.GetX() + _extent_two.GetX() / 2.0, _extent_one.GetY() + _extent_two.GetY() / 2.0)); }
void Trendline::UpdateTrendline(Point2DInt_t* pointsArray) { m_points[m_count].x = (*pointsArray).y; m_points[m_count].y = (*pointsArray).x; m_count++; yAxisValuesSum += m_points[m_count-1].y; xAxisValuesSum += m_points[m_count-1].x; xySum += m_points[m_count-1].x*m_points[m_count-1].y; xxSum += m_points[m_count-1].x*m_points[m_count-1].x; CalculateSlope(); CalculateIntercept(); }
void Trendline::Initialize() { yAxisValuesSum = 0; xAxisValuesSum = 0; xxSum = 0; xySum = 0; for (int i = 0; i < m_count; i++) { yAxisValuesSum += m_points[i].y; xAxisValuesSum += m_points[i].x; xySum += m_points[i].x*m_points[i].y; xxSum += m_points[i].x*m_points[i].x; } CalculateSlope(); CalculateIntercept(); }
void Trendline::EraseLastPointsPrecentage(float pointsPrecentage) { //cout << "m_count = " << m_count << " m_slope = " << m_slope << " m_intercept = " << m_intercept; int placeArrayToRemove = (float)m_count*(1-pointsPrecentage); for(int i = placeArrayToRemove; i < m_count ; i++) { yAxisValuesSum -= m_points[i].y; xAxisValuesSum -= m_points[i].x; xySum -= m_points[i].x*m_points[i].y; xxSum -= m_points[i].x*m_points[i].x; } m_count = placeArrayToRemove; CalculateSlope(); CalculateIntercept(); // cout << "New m_count = " << m_count << " m_slope = " << m_slope << " m_intercept = " << m_intercept << "\n"; }
bool Line::ContainsPoint(const Point3D& point) const { Float slope = CalculateSlope(p1, point); return (Smooth(slope) == Smooth(GetSlope())); }
void Line::SetPointTwo(double x, double y) { _extent_two = Vector2D(x, y); CalculateLengthSquared(); CalculateSlope(); Shape::SetPosition(a2de::Vector2D(_extent_one.GetX() + _extent_two.GetX() / 2.0, _extent_one.GetY() + _extent_two.GetY() / 2.0)); }