Ejemplo n.º 1
0
std::string CLineSegment::ToString() const
{
    return "Line Segment <" + boost::lexical_cast<std::string>(m_start.GetX()) + ", " +
           boost::lexical_cast<std::string>(m_start.GetY()) + ">, <" + boost::lexical_cast<std::string>(m_end.GetX()) +
           ", " + boost::lexical_cast<std::string>(m_end.GetY()) + "> S=" + boost::lexical_cast<std::string>(GetArea()) +
           " P=" + boost::lexical_cast<std::string>(GetPerimeter());
}
Ejemplo n.º 2
0
std::string CRectangle::ToString() const
{
	std::string output = "Rectangle ";
	output += "\n";
	output += "pos: ";
	output += m_upperLeftCorner.ToString();
	output += "\n";
	output += "S: " + std::to_string(GetArea());
	output += "\n";
	output += "P: ";
	output += std::to_string(GetPerimeter());
	output += "\n";
	output += "Border Color: ";
	output += std::to_string(GetBorderColor().r);
	output += " ";
	output += std::to_string(GetBorderColor().g);
	output += " ";
	output += std::to_string(GetBorderColor().b);
	output += "\n";
	output += "Fill Color: ";
	output += std::to_string(GetFillColor().r);
	output += " ";
	output += std::to_string(GetFillColor().g);
	output += " ";
	output += std::to_string(GetFillColor().b);
	output += "\n";
	output += "=============================";
	return output;
}
Ejemplo n.º 3
0
Archivo: Point.cpp Proyecto: intmpg/OOP
std::string CPoint::ToString() const
{
	std::stringstream ss;
	ss << "point <" << m_pos.x << ", " << m_pos.y << ">, S = " << GetArea()
		<< ", P = " << GetPerimeter();
	return ss.str();
}
Ejemplo n.º 4
0
std::string CPoint::ToString() const
{
	std::stringstream stream;
	stream << "Point <" << m_x << "," << m_y << ">";
	stream << ", P=" << GetPerimeter() << ", S=" << GetArea();
	return stream.str();
}
Ejemplo n.º 5
0
std::string CTriangle::GetDescription()const
{
	return "Triangle <<" + std::to_string(m_points[0].x) + ", " + std::to_string((m_points[0].y)) +
		"><" + std::to_string((m_points[1].x)) + ", " + std::to_string((m_points[1].y))
		+ "><" + std::to_string((m_points[2].x)) + ", " + std::to_string((m_points[2].y))
		+ ">>, S = " + std::to_string(GetArea()) + ", P = " + std::to_string(GetPerimeter());
}
Ejemplo n.º 6
0
std::string CTriangle::ToString() const
{
	std::stringstream stream;
	stream << "Triangle <<" << m_firstVertex.GetX() << "," << m_firstVertex.GetY() << ">";
	stream << "<" << m_secondVertex.GetX() << "," << m_secondVertex.GetY() << ">";
	stream << "<" << m_thirdVertex.GetX() << "," << m_thirdVertex.GetY() << ">>";
	stream << ", Perimeter=" << GetPerimeter() << ", Area=" << GetArea();
	return stream.str();
}
Ejemplo n.º 7
0
float CTriangle::GetArea() const
{
	float halfPerimeter = GetPerimeter() / 2.f;
	float lengthFirtsLine = m_firstLine.GetPerimeter();
	float lengthSecondLine = m_secondLine.GetPerimeter();
	float lengthThirdLine = m_thirdLine.GetPerimeter();

	return sqrtf(halfPerimeter * (halfPerimeter - lengthFirtsLine)
								* (halfPerimeter - lengthSecondLine)
								* (halfPerimeter - lengthThirdLine));
}
Ejemplo n.º 8
0
std::string CRectangle::GetStringRepresentation()const
{
	std::ostringstream result;
	result.setf(std::ios_base::fixed, std::ios_base::floatfield);
	result << std::setprecision(2);

	result << "Rectangle <" << m_mainCorner->m_position.x << ", "
		<< m_mainCorner->m_position.y << ">, <" << m_width << ", " << m_height << "> "
		<< GetSquare() << ", P=" << GetPerimeter() << std::endl;
	
	return result.str();
}
Ejemplo n.º 9
0
std::string CCircle::ToString() const
{
	std::stringstream ss;
	ss << std::fixed << std::setprecision(2) << "circle <" << 
		m_center.GetPosition().first << ", " << 
		m_center.GetPosition().second << ">, R = " << 
		GetRadius() << ", S = " << 
		GetArea() << ", P = " << 
		GetPerimeter() << ", " << 
		m_outlineColor << ", " << 
		m_fillColor;
	return ss.str();
}
Ejemplo n.º 10
0
int _tmain(int argc, _TCHAR* argv[])
{
	std::ifstream fin("input.txt");
	std::ofstream fout("output.txt");

	std::string type;
	while (fin >> type)
	{
		auto shape = CShapeReader::ReadShape(fin, type);
		fout << type << " " << "P=" << std::setprecision(6) << shape->GetPerimeter() << "; S=" << shape->GetArea() << std::endl;
	}

	return 0;
}
Ejemplo n.º 11
0
std::string CRectangle::ToString() const
{
	std::stringstream ss;
	std::pair<double, double> position = m_position.GetPosition();
	ss << std::fixed << std::setprecision(2) << "rectangle <" << 
		position.first << ", " << 
		position.second << "> " << "width = " << 
		m_width << ", height = " << 
		m_height << ", S = " << 
		GetArea() << ", P = " << 
		GetPerimeter() << ", " << 
		m_outlineColor << ", " << 
		m_fillColor;
	return ss.str();
}
Ejemplo n.º 12
0
void SpermParamCalc::OnSperMopyParamCalc()  // 参数计算
{
	// TODO: Add your control notification handler code here
	
	double	_length = 0.0;
	double	_width  = 0.0;
	double	_area   = 0.0;
	double	_ellipticity = 0.0;
	double	_perfor_area = 0.0;
	double	_head_area   = 0.0; 
	double	_perimeter   = 0.0;
    double  _head_perfor_area = 0.0;

	double	_tail_length = 0.0;
	double	_tail_width  = 0.0;
	double	_tail_angle  = 0.0;

	double  _extension   = 0.0;
	double  _symmetry    = 0.0;
	double  _ruga        = 0.0;

    OnGetHeadEdge();

	_length = GetLength();
	_width  = GetWidth();
    _area   = GetArea();
    _perimeter   = GetPerimeter();
	_ellipticity = _width < 1.0e-6 ? 0.0 : _length/_width;
    _perfor_area = GetPerforArea();
	_head_area   = GetHeadArea();
    _head_perfor_area = _area < 1.0e-6 ? 0.0 : _perfor_area/_area;

	_tail_length = GetTailLength();
	_tail_width  = GetTailWidth();
	_tail_angle  = GetTailAngle();

	// 计算伸展度((L-W)/(L+W)
	_extension   = ( ((_length + _width)<1.0e-6) || ((_length - _width)< 1.0e-6) ) 
		? 0.0 : (_length - _width)/(_length + _width); 

	// 计算对称度(πLW/4S)
	_symmetry    = _area<1.0e-6 ? 0.0 : PI*_length*_width/(4*_area);
	
	// 计算皱褶度(4πS/P^2)
	_ruga        = _perimeter*_perimeter<1.0e-6 ? 0.0 : (4*PI*_area/(_perimeter*_perimeter));

// 	OnMarkEllipse();   // 标记椭圆轮廓
//  OnMarkProlate();   // 标记长轴
// 	OnMarkMinorAxis(); // 标记短轴
//  OnMarkTailAxis();  // 标记尾轴

	m_SperMopyParameter.m_length        = _length;    
	m_SperMopyParameter.m_width         = _width;
	m_SperMopyParameter.m_area          = _area;
	m_SperMopyParameter.m_ellipticity       = _ellipticity;
	m_SperMopyParameter.m_perfor_area       =  _perfor_area;
	m_SperMopyParameter.m_head_area         =  _head_area;
	m_SperMopyParameter.m_perimeter         = _perimeter;
	m_SperMopyParameter.m_head_perfor_area  = _head_perfor_area;

	m_SperMopyParameter.m_tail_length       = _tail_length;
	m_SperMopyParameter.m_tail_width        = _tail_width;
	m_SperMopyParameter.m_tail_angle        = _tail_angle;

	m_SperMopyParameter.m_extension   = _extension; 
	m_SperMopyParameter.m_symmetry    = _symmetry;
	m_SperMopyParameter.m_ruga        = _ruga;
}
Ejemplo n.º 13
0
std::string CRectangle::GetDescription() const
{
	return  "Rectangle <<" + std::to_string(m_firstPoint.x) + ", " + std::to_string(m_firstPoint.y)
		+ "><" + std::to_string(m_secondPoint.x) + ", " + std::to_string(m_secondPoint.y) + 
		">>, S = " + std::to_string(GetArea()) + ", P = " + std::to_string(GetPerimeter());
}
Ejemplo n.º 14
0
std::string CDot::ToString() const
{
	return "Point < " + CShape::Convert(m_coordinates.first) +  ", " + CShape::Convert(m_coordinates.second) + +" S=" +
		CShape::Convert(GetArea()) +  " P=" + CShape::Convert(GetPerimeter()) + "> ";
}
Ejemplo n.º 15
0
double CTriangle::GetArea()const
{
	double p = GetPerimeter() / 2;
	return sqrt(p * (p - m_side1) * (p - m_side2) * (p - m_side3));
}
Ejemplo n.º 16
0
double CTriangle::GetArea() const
{
	double p = GetPerimeter() / 2;
	return sqrt(p * (p - m_firstSide) * (p - m_secondSide) * (p - m_thirdSide));
}
Ejemplo n.º 17
0
std::string CCircle::GetDescription()const
{
	return "Circle <" + std::to_string(m_pointCenter.x) + ", " +
		std::to_string(m_pointCenter.y) + ">, R = " + std::to_string(m_radius) + 
		", S = " + std::to_string(GetArea()) + ", P = " + std::to_string(GetPerimeter());
}
Ejemplo n.º 18
0
std::string CTriangle::ToString() const
{
	return "Triangle <" + boost::lexical_cast<std::string>(m_p1.GetX()) + ", " + boost::lexical_cast<std::string>(m_p1.GetY()) + "> " +
		" <" + boost::lexical_cast<std::string>(m_p2.GetX()) + ", " + boost::lexical_cast<std::string>(m_p2.GetY()) + "> " +
		" <" + boost::lexical_cast<std::string>(m_p3.GetX()) + ", " + boost::lexical_cast<std::string>(m_p3.GetY()) + ">" +
		" S=" + boost::lexical_cast<std::string>(GetArea()) + " P=" + boost::lexical_cast<std::string>(GetPerimeter());
}
Ejemplo n.º 19
0
std::string CTriangle::ToString() const
{
	return "Triangle <" + m_dot1.ToString() + " , " + m_dot2.ToString() + " , " + m_dot3.ToString()
		+ " , " + m_line1.ToString() + "," + m_line2.ToString() + " , " + m_line3.ToString()
		+ " S=" + CSolidShape::Convert(GetArea()) + " P=" + CSolidShape::Convert(GetPerimeter()) + "> ";
}
Ejemplo n.º 20
0
double CTriangle::GetHalfPerimeter() const
{
	return GetPerimeter() / 2;
}
Ejemplo n.º 21
0
std::string CLineSegment::ToString() const
{
	return "Line <" + m_start.ToString() + ", " + m_end.ToString() + ", " + " S=" + CShape::Convert(GetArea())
		+ " P=" + CShape::Convert(GetPerimeter()) + "> ";
}
Ejemplo n.º 22
0
std::string CTriangle::ToString() const
{
	return "Triangle <" + std::to_string(m_point1.GetX()) + ", " + std::to_string(m_point1.GetY()) + ">, <" + std::to_string(m_point2.GetX()) + ", " + std::to_string(m_point2.GetY()) + ">, <" + std::to_string(m_point3.GetX()) + ", " + std::to_string(m_point3.GetY()) + ">, S = " + std::to_string(GetArea()) + ", P = " + std::to_string(GetPerimeter()) + "\n";

}
Ejemplo n.º 23
0
float CTriangle::GetArea() const
{
	float semiperimeter = GetPerimeter() / 2.0f;
	return sqrt(semiperimeter * (semiperimeter - GetFirstSideLength()) * (semiperimeter - GetSecondSideLength()) *
		(semiperimeter - GetThirdSideLength()));
}