Ejemplo n.º 1
0
Shape Shape::RotateShape(LBF_DATA angleRange)
{
	Shape dstShape;

	if (m_Shape.size() < 1)
		return dstShape;

	dstShape.resize(m_Shape.size());

	std::random_device randDev;
	std::mt19937 generator(randDev());
	std::uniform_real_distribution<LBF_DATA> distr(0, 1);

	LBF_DATA rotAngle = 2 * angleRange * distr(generator) - angleRange;
	LBF_POINT rotCenter = GetMeanPoint();
	LBF_DATA sinT = std::sin(rotAngle * PI / 180);
	LBF_DATA cosT = std::cos(rotAngle * PI / 180);
	for (int i = 0; i < m_Shape.size(); i++)
	{
		dstShape.m_Shape[i].x = rotCenter.x + cosT*(m_Shape[i].x - rotCenter.x) - sinT*(m_Shape[i].y - rotCenter.y);
		dstShape.m_Shape[i].y = rotCenter.y + sinT*(m_Shape[i].x - rotCenter.x) + cosT*(m_Shape[i].y - rotCenter.y);
	}

	return dstShape;
}
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main(int argc, char* argv[])
{
    const int ActualGridWidth = 1920;
	const int ActualGridHeight = 1080;

	const int MSLevel = 2;
	const int MSGridWidth = ActualGridWidth * MSLevel;
	const int MSGridHeight = ActualGridHeight * MSLevel;

	std::random_device randDev;
	std::default_random_engine randEng(randDev());
	std::uniform_int_distribution<int> dist(0, MSLevel);

	for (auto i = 0; i < ActualGridWidth; i++)
	{
		for (auto j = 0; j < ActualGridHeight; j++)
		{
			// Pick random cell
			auto cellX = i * MSLevel + dist(randEng);
			auto cellY = j * MSLevel + dist(randEng);
			
			// Now compute the ray using MSGridWidth and MSGridHeight
		}
	}
}
Ejemplo n.º 3
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main(int argc, char* argv[])
{
    std::ofstream ofile("out.dat", std::ios::binary);

	std::random_device randDev;
	std::default_random_engine defEngine(randDev());
	std::uniform_int_distribution<int> dist(0, 9);
    auto printSomeNumbers = [&](std::default_random_engine& engine) { for(int i=0; i < 10; i++) { std::cout << dist(engine) << " "; } std::cout << std::endl; };

	std::cout << "Start sequence: " << std::endl;
	printSomeNumbers(defEngine);
	
	ofile << defEngine;
	ofile.close();

	std::default_random_engine fileEngine;

	std::ifstream ifile("out.dat", std::ios::binary);
	ifile >> fileEngine;

	std::cout << "Orig engine: "; printSomeNumbers(defEngine);
	std::cout << "File engine: "; printSomeNumbers(fileEngine);

	std::cin.get();
	return 0;
}