示例#1
0
Point Scene::random_point(const CGAL::Bbox_3& bbox)
{
    FT x = random_in(bbox.xmin(),bbox.xmax());
    FT y = random_in(bbox.ymin(),bbox.ymax());
    FT z = random_in(bbox.zmin(),bbox.zmax());
    return Point(x,y,z);
}
示例#2
0
Vector Scene::random_vector()
{
    FT x = random_in(0.0,1.0);
    FT y = random_in(0.0,1.0);
    FT z = random_in(0.0,1.0);
    return Vector(x,y,z);
}
typename K::Point_3 random_point_in(const CGAL::Bbox_3& bbox)
{
  typedef typename K::FT FT;
  FT x = (FT)random_in(bbox.xmin(),bbox.xmax());
  FT y = (FT)random_in(bbox.ymin(),bbox.ymax());
  FT z = (FT)random_in(bbox.zmin(),bbox.zmax());
  return typename K::Point_3(x,y,z);
}
示例#4
0
文件: prime.c 项目: thekoc/CCpp2016
long long int is_prime(long long int p, int centeainty) {
    if (p % 2 == 0 && p != 2) {
        return 0;
    } else {
        long long int a;
        a = random_in(p);
        for (size_t i = 0; i < centeainty; i++, a = random_in(p)) {
            long long int result = expmod_for_miller_test(a, p - 1, p);
            if (result == 0 || result != 1) {
                return 0;
            }
        }
        return 1;
    }
}
示例#5
0
void TreeSystem::make_ground(
	float thickness,
	float base_angle,
	float delta_angle,
	const sf::Color& base_color,
	const ColorTransform& deltas)
{
	const float density_factor = 1.5;
	const float block_w = 5;
	const float block_h = 1;
	const float block_area = block_w * block_h;
	const float underground_depth = 5;

	auto phys = physicsDimensions();
	auto phys2 = physicsHalfDimensions();
	const float area = (thickness + underground_depth) * phys.x;
	const unsigned density = (area * density_factor) / block_area;

	blocks.reserve(blocks.size() + density + 1);

	polygonDef def;
	def.bodyDef.active = false;
	def.bodyDef.fixedRotation = true;
	def.bodyDef.type = b2_staticBody;
	def.shape.SetAsBox(phys2.x, thickness/2);
	def.bodyDef.angle = 0;
	def.bodyDef.position.Set(phys2.x, phys.y - (thickness/2));

	blocks.emplace_back(
		make_shape(world(), def),
		base_color);
	
	def.shape.SetAsBox(block_w, block_h);
	addProgress(1);

	const b2Vec2 topLeft(0, phys.y - thickness);
	const b2Vec2 bottomRight(phys.x, phys.y + underground_depth);

	maxProgress(blocks.size() + density + 1);
	setProgress(blocks.size());

	for(int i = 0; i < density; ++i)
	{
		def.bodyDef.position = random_in(topLeft, bottomRight);
		def.bodyDef.angle = to_radians(randcentered(base_angle, delta_angle));
		add_block(def, deltas.apply(base_color));
		addProgress(1);
	}
}