本文整理汇总了C++中vector2类的典型用法代码示例。如果您正苦于以下问题:C++ vector2类的具体用法?C++ vector2怎么用?C++ vector2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vector2类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: trunk
static vector2 trunk(const vector2& v, number smallestVal)
{
vector2 t;
t.x() = smallestVal * round(v.x() / smallestVal);
t.y() = smallestVal * round(v.y() / smallestVal);
return t;
}
开发者ID:bsumirak,项目名称:ugcore,代码行数:7,代码来源:file_io_tikz.cpp
示例2: x
const vector2 vector2::operator / (const vector2 &v2) const
{
vector2 r;
r.x() = x() / v2.x();
r.y() = y() / v2.y();
return r;
}
开发者ID:lsempe,项目名称:uipg,代码行数:7,代码来源:vector.cpp
示例3: vector2
vector2 vector2::Transform(const vector2& v, const matrix& m)
{
vector2 result = vector2(
(v.x() * m(0,0)) + (v.y() * m(0,1)) + m(3,0),
(v.x() * m(1,0)) + (v.y() * m(1,1)) + m(3,1));
return result;
}
开发者ID:lsempe,项目名称:uipg,代码行数:8,代码来源:vector.cpp
示例4: hitCircle
double hitCircle(vector2 here, vector2 dir, vector2 center, double radius) {
double a = dir.dot(dir);
double b = 2 * dir.dot(here - center);
double c = center.dot(center) + here.dot(here) - 2 * here.dot(center) - radius * radius;
vector<double> sols = equation(a, b, c);
if (sols.empty() || sols[0] < EPSILON) return INF;
return sols[0];
}
开发者ID:MutesK,项目名称:algospot,代码行数:8,代码来源:PINBALL.cpp
示例5: m
vector4 vector4::Transform(const vector2& v, const matrix& m)
{
vector4 result = vector4(
(v.x() * m(0,0)) + (v.y() * m(1,0)) + m(3,0),
(v.x() * m(0,1)) + (v.y() * m(1,1)) + m(3,1),
(v.x() * m(0,2)) + (v.y() * m(1,2)) + m(3,2),
(v.x() * m(0,3)) + (v.y() * m(1,3)) + m(3,3));
return result;
}
开发者ID:lsempe,项目名称:uipg,代码行数:10,代码来源:vector.cpp
示例6: solve
vector<double> solve(vector2 here, vector2 dir, vector<vector2>& center, vector<double>& radius) {
double n = center.size();
dir = dir.normalize();
vector<double> ret;
double cnt=0;
while (cnt < 100) {
double circle = -1;
double time = INF*0.5;
for (double i = 0; i < n; ++i) {
double cand = hitCircle(here, dir, center[i], radius[i] + 1);
if (cand < time) {
time = cand;
circle = i;
}
}
if (circle == -1) break;
cnt++;
ret.push_back(circle);
vector2 contact = here + dir * time;
dir = reflect(here, dir, center[circle], contact);
here = contact;
}
return ret;
}
开发者ID:MutesK,项目名称:algospot,代码行数:26,代码来源:PINBALL.cpp
示例7: init
bool QtWindowSystem::init(const vector2<int>& r, int /*bpp*/, bool /*fullscreen*/)
{
if (view_ == nullptr)
{
// check for Qt Application class instance
if (QApplication::instance() == nullptr)
{
int argc = 0;
static QApplication application(argc, nullptr);
}
view_ = new QtView;
view_->setGeometry(0, 0, r.x(), r.y());
set_format(WindowContextFormat());
}
return true;
}
开发者ID:icedmaster,项目名称:mhe,代码行数:17,代码来源:qt_window_system.cpp
示例8:
edge::edge(vector2 a, vector2 uv_a, float z_a, vector2 b, vector2 uv_b, float z_b) {
if (a.get_y() > b.get_y()) {
this->a = b;
this->uv_a = uv_b;
this->b = a;
this->uv_b = uv_a;
this->z_b = z_a;
this->z_a = z_b;
}
else {
this->a = a;
this->b = b;
this->uv_a = uv_a;
this->uv_b = uv_b;
this->z_a = z_a;
this->z_b = z_b;
}
}
开发者ID:slabo101,项目名称:thirdpillow,代码行数:19,代码来源:edge.cpp
示例9: crush
double crush(vector2 s, vector2 p, vector2 center, int r)
{
// 이차 방정식 ax^2+bx+c=0 형태를 만든다
double a = p.dot(p);
double b = 2*(s-center).dot(p);
double c = center.dot(center)+s.dot(s)-r*r-2*center.dot(s);
double d = b*b - 4*a*c;
// 전혀 안부딪힘
if(d < 0) {
return INFITY;
}
// 시간t의 근은 무조건 양수 2개가 나와야 된다(또는 양수 중근)
// 그 중 작은 값만 취하기 때문에 큰 값은 버린다
double solv = (-b - sqrt(d)) / 2*a;
// 음수가 하나라도 나오면 공은 장애물에 부딪히지 않는다
if(solv < 0) {
return INFITY;
} else {
return solv;
}
}
开发者ID:fisache,项目名称:algorithms,代码行数:24,代码来源:main.cpp
示例10: fn
void fn(vector2 W) {
W.push_back(111);
return;
}
开发者ID:sarenat,项目名称:csc103-lectures,代码行数:4,代码来源:main.cpp
示例11:
// Equality operations
bool vector2::operator == (const vector2 &v) const
{
return ((x() == v.x()) && (y() == v.y()));
}
开发者ID:lsempe,项目名称:uipg,代码行数:5,代码来源:vector.cpp
示例12:
inline
bool operator ==(const vector2 &lhs, const vector2 &rhs) {
return lhs.get_x() == rhs.get_x() && lhs.get_y() == rhs.get_y();
}
开发者ID:nagoya313,项目名称:ngy313,代码行数:4,代码来源:vector.hpp
示例13: main
int main()
{
freopen ("in.txt", "r", stdin);
int n, m, x, y, z, p;
scanf ("%d %d %d %d %d %d", &n, &m, &x, &y, &z, &p);
x %= 4;
y %= 2;
z %= 4;
center = vector2((float)(n) / 2.0f, (float) (m) / 2.0f);
vector2 v;
vector2 location;
printf ("center: "); center.print_debug();
for (int i = 0; i < p; i++)
{
input.get();
if (input.x < center.x)
input.x += 0.5f;
else if (input.x > center.x)
input.x -= 0.5f;
if (input.y < center.y)
input.y += 0.5f;
else if (input.y > center.y)
input.y -= 0.5f;
printf ("input: "); input.print_debug();
v.x = input.x - center.x;
v.y = input.y - center.y;
printf ("v: "); v.print_debug();
v.clockwise(x);
v.print_debug();
input.x = v.x + center.x;
input.y = v.y + center.y;
if (y > 0 && !cmp (input.y, center.y))
input.y = center.y - input.y + center.y;
v.x = input.x - center.x;
v.y = input.y - center.y;
v.counter_clockwise(z);
location.x = center.x + v.x;
location.y = center.y + v.y;
location.print_debug();
}
return 0;
}
开发者ID:elvircrn,项目名称:ccppcodes,代码行数:63,代码来源:C+(17).cpp
示例14: reflect
vector2 reflect(vector2 here, vector2 dir, vector2 center, vector2 contact) {
return (dir - dir.project(contact - center) * 2).normalize();
}
开发者ID:MutesK,项目名称:algospot,代码行数:3,代码来源:PINBALL.cpp
示例15: reflect
// 사영을 이용해 반사 방향벡터를 구한다
vector2 reflect(vector2 p, vector2 b)
{
// 단위벡터로 만들어야 제대로된 답이 나온다
return (p-p.project(b)*2).normalize();
}
开发者ID:fisache,项目名称:algorithms,代码行数:6,代码来源:main.cpp
示例16: project
vector2 project(const vector2& rhs) const {
vector2 r = rhs.normalize();
return r * r.dot(*this);
}
开发者ID:MutesK,项目名称:algospot,代码行数:4,代码来源:PINBALL.cpp
示例17: ccw
// 원점에서 벡터 b 가 벡터 a 의 반시계 방향이면 양수, 시계 방향이면 음수, 평행이면 0 을 반환한다
double ccw(vector2 a, vector2 b) {
return a.cross(b);
}
开发者ID:MJ111,项目名称:algorithm-snippet,代码行数:4,代码来源:nerd.cpp
示例18: MyCB
void MyCB(system::UINT32 msg, system::UINT64 wParam, system::UINT64 lParam)
{
switch(msg)
{
case WM_DESTROY:
case WM_QUIT:
g_quit = true;
break;
case WM_MOUSEMOVE:
g_mousePos.set((float)GET_X_LPARAM(lParam), (float)GET_Y_LPARAM(lParam));
g_mouseLButtonDown = (wParam & MK_RBUTTON);
break;
}
}
开发者ID:mitchellharvey,项目名称:CSpace,代码行数:15,代码来源:main.cpp
注:本文中的vector2类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论