本文整理汇总了C++中geometry类的典型用法代码示例。如果您正苦于以下问题:C++ geometry类的具体用法?C++ geometry怎么用?C++ geometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了geometry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: create_sierpinski
void create_sierpinski(geometry &geom) {
vector<vec3> points;
vector<vec4> colours;
// Three corners of the triangle
array<vec3, 3> v = {vec3(-1.0f, -1.0f, 0.0f), vec3(0.0f, 1.0f, 0.0f), vec3(1.0f, -1.0f, 0.0f)};
// Create random engine - generates random numbers
default_random_engine e;
// Create a distribution. 3 points in array so want 0-2
uniform_int_distribution<int> dist(0, 2);
// Add first point to the geometry
points.push_back(vec3(0.25f, 0.5f, 0.0f));
// Add first colour to the geometry
colours.push_back(vec4(1.0f, 0.0f, 0.0f, 1.0f));
// Add random points using distribution
for (auto i = 1; i < num_points; ++i) {
// *********************************
// Add random point
points.push_back((points[i-1] + v[dist(e)]) /2.0f);
// Add colour - all points red
colours.push_back(vec4(1.0f, 0.0f, 0.0f, 1.0f));
// *********************************
}
// *********************************
// Add buffers to geometry
geom.add_buffer(points, BUFFER_INDEXES::POSITION_BUFFER);
geom.add_buffer(colours, BUFFER_INDEXES::COLOUR_BUFFER);
// *********************************
}
开发者ID:DelbyPicnic,项目名称:set08116,代码行数:28,代码来源:18_Point_Based_Sierpinski.cpp
示例2: load_content
bool load_content() {
geom.set_type(GL_TRIANGLE_STRIP);
// Create quad data
// Positions
vector<vec3> positions{vec3(-1.0f, -1.0f, 0.0f), vec3(1.0f, -1.0f, 0.0f), vec3(-1.0f, 1.0f, 0.0f),
vec3(1.0f, 1.0f, 0.0f)};
// Colours
vector<vec4> colours{vec4(1.0f, 0.0f, 0.0f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f), vec4(1.0f, 0.0f, 0.0f, 1.0f),
vec4(1.0f, 0.0f, 0.0f, 1.0f)};
// Add to the geometry
geom.add_buffer(positions, BUFFER_INDEXES::POSITION_BUFFER);
geom.add_buffer(colours, BUFFER_INDEXES::COLOUR_BUFFER);
// Load in shaders
eff.add_shader("shaders/basic.vert", GL_VERTEX_SHADER);
eff.add_shader("shaders/basic.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Set camera properties
cam.set_position(vec3(10.0f, 10.0f, 10.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
开发者ID:dooglz,项目名称:set08116,代码行数:26,代码来源:17_Full_Transformation.cpp
示例3: spgw_standartize_cell
int spgw_standartize_cell(geometry<VALTYPE,CELL> &inGeom,geometry<VALTYPE,CELL>
&outGeom, float symprec = 1e-5)
{
int num_atoms = inGeom.size();
auto latticev = new VALTYPE[3][3]();
auto position = new VALTYPE[num_atoms][3]();
auto types = new int[num_atoms]();
get_spgdata_from_geom(inGeom,latticev,position,types);
int to_primitive = 1;
int no_idealize = 0;
int num_primitive_atom = spg_standardize_cell(latticev, position, types,
to_primitive, no_idealize,
num_atoms, symprec);
//Get standartized cell back to user
for(int i=0; i<3; i++){
outGeom.cell.v[i].x() = latticev[i][0];
outGeom.cell.v[i].y() = latticev[i][1];
outGeom.cell.v[i].z() = latticev[i][2];
}
for(int i=0; i<num_atoms; i++){
outGeom.add(inGeom.atom_of_type(types[i]),
position[i][0], position[i][1], position[i][2]);
}
return num_primitive_atom;
}
开发者ID:ZloyBabai,项目名称:qpp,代码行数:30,代码来源:spgw.hpp
示例4: neighbor_index_shift_narrow
neighbor_index_shift_narrow(const geometry<2>& geo)
{
index_shift.push_back(-geo.width());
index_shift.push_back(-1);
index_shift.push_back(0);
index_shift.push_back(1);
index_shift.push_back(geo.width());
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例5: get_Clip
geometry UIElement::MakeVisibleGeometry(geometry clip)
{
m_visibleGeometryValid = true;
//gm::RectF bounds = clip.GetBounds();
geometry clipThis = get_Clip();
if (clipThis != nullptr)
{
clip &= clipThis;
}
#ifdef _DEBUG
gm::RectF bounds = clip.GetBounds();
#endif
geometry geom = GetHitGeometry();
#ifdef _DEBUG
gm::RectF bounds2 = geom.GetBounds();
#endif
clip &= geom;
#ifdef _DEBUG
gm::RectF bounds3 = clip.GetBounds();
#endif
size_t nchildren = GetChildrenCount();
for (size_t i = nchildren; i > 0; --i)
{
Visual* child = GetChild(i-1);
geometry geom2 = child->MakeVisibleGeometry(clip);
clip |= geom2;
}
UIElement* shadowTree = get_ShadowTree();
if (shadowTree)
{
geometry geom2 = shadowTree->MakeVisibleGeometry(clip);
#ifdef _DEBUG
gm::RectF bounds5 = geom2.GetBounds();
#endif
clip |= geom2;
}
#ifdef _DEBUG
gm::RectF bounds4 = clip.GetBounds();
#endif
set_VisibleGeometry(clip);
return clip;
}
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:57,代码来源:UIElement.cpp
示例6: load_content
bool load_content() {
// Create cube data - eight corners
// Positions
vector<vec3> positions{
// *********************************
// Add the position data for cube corners here (8 total)
// *********************************
};
// Colours
vector<vec4> colours;
for (auto i = 0; i < positions.size(); ++i) {
colours.push_back(vec4((i + 1) % 2, 0.0f, i % 2, 1.0f));
}
// Create the index buffer
vector<GLuint> indices{
// *********************************
// Add index information here - 3 per triangle, 6 per face, 12 triangles
// Front
// Back
// Right
// Left
// Top
// Bottom
// *********************************
};
// Add to the geometry
geom.add_buffer(positions, BUFFER_INDEXES::POSITION_BUFFER);
geom.add_buffer(colours, BUFFER_INDEXES::COLOUR_BUFFER);
// ****************************
// Add index buffer to geometry
// ****************************
geom.add_index_buffer(indices);
// Load in shaders
eff.add_shader("shaders/basic.vert", GL_VERTEX_SHADER);
eff.add_shader("shaders/basic.frag", GL_FRAGMENT_SHADER);
// Build effect
eff.build();
// Set camera properties
cam.set_position(vec3(10.0f, 10.0f, 10.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
开发者ID:dooglz,项目名称:set08116,代码行数:55,代码来源:22_Indexed_Cube.cpp
示例7: load_content
bool load_content()
{
// **************************
// Set geometry type to quads
// **************************
geom.set_type(GL_QUADS);
// Create quad data
// Positions
vector<vec3> positions
{
// ***********************************************
// Add the four positions of the quad corners here
// ***********************************************
vec3(-1.0f, 1.0f, 0.0f),
vec3(-1.0f, -1.0f, 0.0f),
vec3(1.0f, -1.0f, 0.0f),
vec3(1.0f, 1.0f, 0.0f)
};
// Colours
vector<vec4> colours
{
vec4(1.0f, 0.0f, 0.0f, 1.0f),
vec4(1.0f, 0.0f, 0.0f, 1.0f),
vec4(1.0f, 0.0f, 0.0f, 1.0f),
vec4(1.0f, 0.0f, 0.0f, 1.0f)
};
// Add to the geometry
geom.add_buffer(positions, BUFFER_INDEXES::POSITION_BUFFER);
geom.add_buffer(colours, BUFFER_INDEXES::COLOUR_BUFFER);
// Load in shaders
eff.add_shader(
"..\\resources\\shaders\\basic.vert", // filename
GL_VERTEX_SHADER); // type
eff.add_shader(
"..\\resources\\shaders\\basic.frag", // filename
GL_FRAGMENT_SHADER); // type
// Build effect
eff.build();
// Set camera properties
cam.set_position(vec3(10.0f, 10.0f, 10.0f));
cam.set_target(vec3(0.0f, 0.0f, 0.0f));
auto aspect = static_cast<float>(renderer::get_screen_width()) / static_cast<float>(renderer::get_screen_height());
cam.set_projection(quarter_pi<float>(), aspect, 2.414f, 1000.0f);
return true;
}
开发者ID:Zoeoeh,项目名称:Coursework-ComputerGraphics,代码行数:49,代码来源:main.cpp
示例8: spgw_get_symmetry
void spgw_get_symmetry(generated_group<rotrans<REAL,true> > & G,
geometry<REAL,CELL> & geom,
REAL R = geometry<REAL,CELL>::tol_geom_default) {
int nat = geom.size();
auto lattice = new double[3][3]();
auto position = new double[nat][3]();
auto types = new int[nat]();
get_spgdata_from_geom(geom,lattice,position,types);
int max_size = nat*48, nsymm;
double translation[max_size][3];
int rotation[max_size][3][3];
//std::cout << "before get symmetry\n";
nsymm = spg_get_symmetry(rotation, translation, max_size, lattice, position, types, nat, R);
matrix3<REAL> f2c,c2f;
//std::cout << "after get symmetry\n";
G.group.clear();
for (int i=0; i<3; i++)
for (int j=0; j<3; j++)
f2c(i,j) = geom.cell(i)(j);
c2f = f2c.inverse();
for (int i=0; i<nsymm; i++)
{
//std::cout << "i= " << i << "\n";
matrix3<REAL> rot;
vector3<REAL> transl = {translation[i][0],translation[i][1],translation[i][2]};
for (int j=0; j<3; j++)
for (int k=0; k<3; k++)
rot(j,k) = rotation[i][j][k];
rot = f2c*rot*c2f;
G.group.push_back(rotrans<REAL,true>(f2c*transl,rot,&geom.cell));
}
/*
std::cout << "Leaving get_symmetry\n";
for (int i=0; i<G.group.size(); i++)
std:: cout << G.group[i] << "\n";
*/
}
开发者ID:ZloyBabai,项目名称:qpp,代码行数:49,代码来源:spgw.hpp
示例9: neighbor_index_shift
neighbor_index_shift(const geometry<3>& geo)
{
int wh = geo.plane_size();
int w = geo.width();
for (int z = -1;z <= 1; ++z)
{
int zwh = z*wh;
for (int y = -1;y <= 1; ++y)
{
int yw = y*w;
for (int x = -1;x <= 1; ++x)
index_shift.push_back(x + yw + zwh);
}
}
}
开发者ID:,项目名称:,代码行数:15,代码来源:
示例10: extents_observer_t
extents_observer_t( geometry<REAL, CELL> & g) {
geom = &g;
geom->add_observer(*this);
first_data = true;
aabb.max = vector3<REAL>(0.0, 0.0, 0.0);
aabb.min = vector3<REAL>(0.0, 0.0, 0.0);
}
开发者ID:ZloyBabai,项目名称:qpp,代码行数:7,代码来源:extents_observer.hpp
示例11: TEST
TEST(GeometryLineSegmentTest, OrientationTest2) {
using geometry::Point;
using geometry::orientation;
Point<int> originPt(1000, 1000);
Point<int> endPt(1100, 1000);
Point<int> ccwPt(1050, 1050);
Point<int> colPt(1200, 1000);
Point<int> cwPt(1050, 950);
// Test CCW,
EXPECT_EQ(1, orientation({originPt, endPt}, ccwPt));
// Test Co-linear
EXPECT_EQ(0, orientation({originPt, endPt}, colPt));
// Test CW
EXPECT_EQ(-1, orientation({originPt, endPt}, cwPt));
}
开发者ID:,项目名称:,代码行数:20,代码来源:
示例12: spgw_get_schoenflies
std::string spgw_get_schoenflies(geometry<VALTYPE,CELL> &inGeom, float symprec = 1e-7){
int num_atoms = inGeom.size();
auto latticev = new VALTYPE[3][3]();
auto position = new VALTYPE[num_atoms][3]();
auto types = new int[num_atoms]();
get_spgdata_from_geom(inGeom,latticev,position,types);
char symbol[21];
int num_spg = spg_get_schoenflies(symbol, latticev, position, types, num_atoms, symprec);
return std::string(symbol);
}
开发者ID:ZloyBabai,项目名称:qpp,代码行数:12,代码来源:spgw.hpp
示例13: Bisect
Argument Bisect(Function f,
Argument const& lower_bound,
Argument const& upper_bound) {
using Value = decltype(f(lower_bound));
Value const zero{};
Value f_upper = f(upper_bound);
Value f_lower = f(lower_bound);
if (f_upper == zero) {
return upper_bound;
}
if (f_lower == zero) {
return lower_bound;
}
CHECK(f_lower > zero && zero > f_upper || f_lower < zero && zero < f_upper)
<< "\nlower: " << lower_bound << " :-> " << f_lower << ", "
<< "\nupper: " << upper_bound << " :-> " << f_upper;
Argument lower = lower_bound;
Argument upper = upper_bound;
for (;;) {
Argument const middle =
Barycentre<Argument, double>({lower, upper}, {1, 1});
// The size of the interval has reached one ULP.
if (middle == lower || middle == upper) {
return middle;
}
Value const f_middle = f(middle);
if (f_middle == zero) {
return middle;
} else if (Sign(f_middle) == Sign(f_upper)) {
upper = middle;
} else {
lower = middle;
}
}
}
开发者ID:,项目名称:,代码行数:35,代码来源:
示例14: light_radius_for_visibility
void light_radius_for_visibility(point_light_component * view, const position_component3d * pos)
{
constexpr double sweep_degrees_radians = 2 * DEGRAD;
constexpr double three_sixy_degrees_radians = 360 * DEGRAD;
view->last_visibility.clear();
// You can always see yourself
const int16_t x = pos->pos.x;
const int16_t y = pos->pos.y;
const uint8_t z = pos->pos.z;
const uint8_t region_idx = pos->pos.region;
const int my_idx = get_tile_index(x, y, z);
const int radius = view->light_range;
view->last_visibility.push_back(my_idx);
region_t * current_region = world::planet->get_region(region_idx);
// Sweep around
for (double angle = 0; angle < three_sixy_degrees_radians; angle += sweep_degrees_radians)
{
double this_radius = radius;
pair<int, int> destination = project_angle(x, y, this_radius, angle);
for (int lz = z - radius; lz < z + radius; ++lz)
{
bool blocked = false;
line_func_3d(x, y, z, destination.first, destination.second, lz,
[&blocked,view,current_region] (int tx, int ty, int tz)
{
if (tx < 0 or tx > REGION_WIDTH or ty < 0 or ty > REGION_HEIGHT or tz<0 or tz>REGION_DEPTH) return;
const int index = get_tile_index(tx,ty,tz);
if (!blocked)
{
if (tx >=0 and tx < REGION_WIDTH and ty>=0 and ty<REGION_HEIGHT and tz>0 and tz<REGION_DEPTH)
{
view->last_visibility.push_back(index);
}
// FIXME: More block reasons
tile_t * tile = ¤t_region->tiles[index];
if (tile->flags.test( TILE_OPTIONS::VIEW_BLOCKED ) )
{
blocked = true;
}
}
});
}
}
}
开发者ID:Zigkurat,项目名称:bgame,代码行数:51,代码来源:global_illumination_system.cpp
示例15: NotNull
TEST_F(BodyTest, RotatingSerializationSuccess) {
EXPECT_FALSE(rotating_body_.is_massless());
EXPECT_FALSE(rotating_body_.is_oblate());
serialization::Body message;
RotatingBody<World> const* cast_rotating_body;
rotating_body_.WriteToMessage(&message);
EXPECT_TRUE(message.has_massive_body());
EXPECT_FALSE(message.has_massless_body());
EXPECT_TRUE(message.massive_body().HasExtension(
serialization::RotatingBody::extension));
EXPECT_EQ(17, message.massive_body().gravitational_parameter().magnitude());
serialization::RotatingBody const rotating_body_extension =
message.massive_body().GetExtension(
serialization::RotatingBody::extension);
EXPECT_EQ(3, rotating_body_extension.reference_angle().magnitude());
EXPECT_EQ(4,
rotating_body_extension.reference_instant().scalar().magnitude());
EXPECT_EQ(angular_velocity_,
AngularVelocity<World>::ReadFromMessage(
rotating_body_extension.angular_velocity()));
// Dispatching from |MassiveBody|.
not_null<std::unique_ptr<MassiveBody const>> const massive_body =
MassiveBody::ReadFromMessage(message);
EXPECT_EQ(rotating_body_.gravitational_parameter(),
massive_body->gravitational_parameter());
cast_rotating_body = dynamic_cast<RotatingBody<World> const*>(&*massive_body);
EXPECT_THAT(cast_rotating_body, NotNull());
EXPECT_EQ(rotating_body_.gravitational_parameter(),
cast_rotating_body->gravitational_parameter());
EXPECT_EQ(rotating_body_.angular_velocity(),
cast_rotating_body->angular_velocity());
EXPECT_EQ(rotating_body_.AngleAt(Instant()),
cast_rotating_body->AngleAt(Instant()));
// Dispatching from |Body|.
not_null<std::unique_ptr<Body const>> const body =
Body::ReadFromMessage(message);
cast_rotating_body = dynamic_cast<RotatingBody<World> const*>(&*body);
EXPECT_THAT(cast_rotating_body, NotNull());
EXPECT_EQ(rotating_body_.gravitational_parameter(),
cast_rotating_body->gravitational_parameter());
EXPECT_EQ(rotating_body_.angular_velocity(),
cast_rotating_body->angular_velocity());
EXPECT_EQ(rotating_body_.AngleAt(Instant()),
cast_rotating_body->AngleAt(Instant()));
}
开发者ID:tsal,项目名称:Principia,代码行数:48,代码来源:body_test.cpp
示例16: TestRotatingBody
void TestRotatingBody() {
using F = Frame<Tag, tag, true>;
AngularVelocity<F> const angular_velocity =
AngularVelocity<F>({-1 * Radian / Second,
2 * Radian / Second,
5 * Radian / Second});
auto const rotating_body =
RotatingBody<F>(17 * SIUnit<GravitationalParameter>(),
typename RotatingBody<F>::Parameters(
2 * Metre,
3 * Radian,
Instant() + 4 * Second,
angular_velocity));
serialization::Body message;
RotatingBody<F> const* cast_rotating_body;
rotating_body.WriteToMessage(&message);
EXPECT_TRUE(message.has_massive_body());
EXPECT_FALSE(message.has_massless_body());
EXPECT_TRUE(message.massive_body().HasExtension(
serialization::RotatingBody::extension));
not_null<std::unique_ptr<MassiveBody const>> const massive_body =
MassiveBody::ReadFromMessage(message);
EXPECT_EQ(rotating_body.gravitational_parameter(),
massive_body->gravitational_parameter());
cast_rotating_body = dynamic_cast<RotatingBody<F> const*>(&*massive_body);
EXPECT_THAT(cast_rotating_body, NotNull());
}
开发者ID:tsal,项目名称:Principia,代码行数:30,代码来源:body_test.cpp
示例17: UnitQuaternion
float Transform3D::norm(Transform3D T){
float pos_norm = arma::norm(T.translation());
UnitQuaternion q = UnitQuaternion(Rotation3D(T.submat(0,0,2,2)));
float angle = q.getAngle();
//TODO: how to weight these two?
return pos_norm + Rotation3D::norm(T.rotation());
}
开发者ID:JakeFountain,项目名称:AutocalibrationResearch,代码行数:7,代码来源:Transform3D.cpp
示例18: Instant
TEST_F(CheckpointerTest, CreateUnconditionally) {
Instant const t = Instant() + 10 * Second;
EXPECT_CALL(writer_, Call(_));
checkpointer_.CreateUnconditionally(t);
Message m;
EXPECT_CALL(m, MergeFrom(_));
EXPECT_EQ(t, checkpointer_.WriteToMessage(&m));
}
开发者ID:mockingbirdnest,项目名称:Principia,代码行数:8,代码来源:checkpointer_test.cpp
示例19: fmin
float Rotation3D::norm(Rotation3D T) {
UnitQuaternion q = UnitQuaternion(T);
// Get angle between -2Pi and 2pi
float angle = q.getAngle();
// Just want magnitude
float theta = std::fabs(angle);
// But rotating more that Pi in one direction is equivalent to a rotation in the other direction
return std::fmin(2 * M_PI - theta, theta);
}
开发者ID:NUbots,项目名称:NUbots,代码行数:9,代码来源:Rotation3D.cpp
示例20:
void compute_2body_terms() {
std::cout << "Compute two body terms \n";
for (size_t i = 0; i < geom->nat(); i++)
for (size_t j = i; j < geom->nat(); j++)
if (i != j) {
int type1 = geom->type_table(i);
int type2 = geom->type_table(j);
int type_1 = std::min(type1, type2);
int type_2 = std::max(type1, type2);
int _i = i;
int _j = j;
if (type1 != type_1) {
_i = j;
_j = i;
}
auto it = cache_pot_2body.find(std::make_tuple(type_1, type_2));
if (it != cache_pot_2body.end())
for (auto &pot : it->second) {
fmt::print(std::cout,
"COMPUTE t1b = {}, t2b = {}, t1a = {}, t2a = {},"
" ib = {}, jb = {}, ia = {}, ja = {}, pot = {}, val={}\n",
type1,
type2,
type_1,
type_2,
i,
j,
_i,
_j,
pot.pot_name,
std::get<0>(pot.fn_en)((geom->pos(_i) - geom->pos(_j)).norm(),
pot.param_pack));
}
}
};
开发者ID:ZloyBabai,项目名称:qpp,代码行数:44,代码来源:cls_pot.cpp
注:本文中的geometry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论