本文整理汇总了C++中vector2类的典型用法代码示例。如果您正苦于以下问题:C++ vector2类的具体用法?C++ vector2怎么用?C++ vector2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vector2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: x
const vector2 vector2::operator / (const vector2 &v2) const
{
vector2 r;
r.x() = x() / v2.x();
r.y() = y() / v2.y();
return r;
}
示例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;
}
示例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];
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例10: fn
void fn(vector2 W) {
W.push_back(111);
return;
}
示例11:
// Equality operations
bool vector2::operator == (const vector2 &v) const
{
return ((x() == v.x()) && (y() == v.y()));
}
示例12:
inline
bool operator ==(const vector2 &lhs, const vector2 &rhs) {
return lhs.get_x() == rhs.get_x() && lhs.get_y() == rhs.get_y();
}
示例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;
}
示例14: reflect
vector2 reflect(vector2 here, vector2 dir, vector2 center, vector2 contact) {
return (dir - dir.project(contact - center) * 2).normalize();
}
示例15: reflect
// 사영을 이용해 반사 방향벡터를 구한다
vector2 reflect(vector2 p, vector2 b)
{
// 단위벡터로 만들어야 제대로된 답이 나온다
return (p-p.project(b)*2).normalize();
}