本文整理汇总了C++中math::Vector2::y方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2::y方法的具体用法?C++ Vector2::y怎么用?C++ Vector2::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math::Vector2
的用法示例。
在下文中一共展示了Vector2::y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: values
void
MeshBase::setVertex(int i, const Math::Vector2 &v)
{
if (!m_vdata->set(i, v.x(), v.y()))
MMWARNING("Failed to assign values (%f, %f) to vertex %d",
v.x(), v.y(), i);
}
示例2: aspectRatioFix
template<UnsignedInt dimensions, class T> typename DimensionTraits<dimensions, T>::MatrixType aspectRatioFix(AspectRatioPolicy aspectRatioPolicy, const Math::Vector2<T>& projectionScale, const Vector2i& viewport) {
/* Don't divide by zero / don't preserve anything */
if(projectionScale.x() == 0 || projectionScale.y() == 0 || viewport.x() == 0 || viewport.y() == 0 || aspectRatioPolicy == AspectRatioPolicy::NotPreserved)
return {};
Math::Vector2<T> relativeAspectRatio = Math::Vector2<T>(viewport)*projectionScale;
/* Extend on larger side = scale larger side down
Clip on smaller side = scale smaller side up */
return Camera<dimensions, T>::aspectRatioScale(
(relativeAspectRatio.x() > relativeAspectRatio.y()) == (aspectRatioPolicy == AspectRatioPolicy::Extend) ?
Vector2(relativeAspectRatio.y()/relativeAspectRatio.x(), T(1.0)) :
Vector2(T(1.0), relativeAspectRatio.x()/relativeAspectRatio.y()));
}
示例3: draw_text
void RendererPlplot::draw_text(const math::Vector2 &c, const math::Vector2 &dir,
const std::string &str, TextAlignMask a, int size, const Rgb &rgb)
{
double j = .5;
if (a & TextAlignLeft)
j = 0.;
else if (a & TextAlignRight)
j = 1.;
_pls->schr(size/3., 1.);
_pls->col0(get_color_id(rgb));
_pls->ptex(c.x(), c.y(), dir.x(), dir.y(), j, str.c_str());
}
示例4: aspectRatioFix
template<UnsignedInt dimensions, class T> MatrixTypeFor<dimensions, T> aspectRatioFix(AspectRatioPolicy aspectRatioPolicy, const Math::Vector2<T>& projectionScale, const Vector2i& viewport) {
/* Don't divide by zero / don't preserve anything */
if(projectionScale.x() == 0 || projectionScale.y() == 0 || viewport.x() == 0 || viewport.y() == 0 || aspectRatioPolicy == AspectRatioPolicy::NotPreserved)
return {};
CORRADE_INTERNAL_ASSERT((projectionScale > Math::Vector2<T>(0)).all() && (viewport > Vector2i(0)).all());
Math::Vector2<T> relativeAspectRatio = Math::Vector2<T>(viewport)*projectionScale;
/* Extend on larger side = scale larger side down
Clip on smaller side = scale smaller side up */
return MatrixTypeFor<dimensions, T>::scaling(Math::Vector<dimensions, T>::pad(
(relativeAspectRatio.x() > relativeAspectRatio.y()) == (aspectRatioPolicy == AspectRatioPolicy::Extend) ?
Math::Vector2<T>(relativeAspectRatio.y()/relativeAspectRatio.x(), T(1)) :
Math::Vector2<T>(T(1), relativeAspectRatio.x()/relativeAspectRatio.y()), T(1)));
}
示例5: draw_point
void RendererPlplot::draw_point(const math::Vector2 &v, const Rgb &rgb, enum PointStyle s)
{
int code;
_pls->col0(get_color_id(rgb));
switch (s)
{
default:
case PointStyleDot:
code = 1;
break;
case PointStyleCross:
code = 2;
break;
case PointStyleRound:
code = 4;
break;
case PointStyleSquare:
code = 6;
break;
case PointStyleTriangle:
code = 11;
break;
}
PLFLT x = v.x(), y = v.y();
_pls->poin(1, &x, &y, code);
}
示例6: draw_circle
void RendererPlplot::draw_circle(const math::Vector2 &c, double r,
const Rgb &rgb, bool filled)
{
_pls->col0(get_color_id(rgb));
std::cout << "draw_circle was not tested (added 8th parameter to compile" << std::endl;
exit(-1);
_pls->arc(c.x(), c.y(), r, r, 0., 360., 360., filled);
}
示例7: inside
bool TRegularPolygon::inside(const Math::Vector2 &point) const
{
double d = Math::square(point.x()) + Math::square(point.y());
// check against circumscribed circle
if (d > Math::square(_radius))
return false;
// check against inscribed circle
if (d < Math::square(_i_radius))
return true;
Math::VectorPair2 e(get_edge(point));
return ((point.y() - e.y0()) * (e.x1() - e.x0()) -
(point.x() - e.x0()) * (e.y1() - e.y0()) > 0);
}
示例8: cos
Math::VectorPair2 TRegularPolygon::get_edge(const Math::Vector2 &point) const
{
// find sector start angle
double a = Math::lp_floor(atan2(point.y(), point.x()) - _angle, (double)_edge_cnt / (2.0 * M_PI));
// find sector edge coordinates
return Math::VectorPair2(_radius * cos(_angle + a), _radius * sin(_angle + a),
_radius * cos(_angle + a + _a_step), _radius * sin(_angle + a + _a_step));
}
示例9: normal
void TCurveBase::normal(Math::Vector3 &normal, const Math::Vector3 &point) const
{
Math::Vector2 d;
derivative(point.project_xy(), d);
normal = Math::Vector3(d.x(), d.y(), -1.0);
normal.normalize();
}
示例10: derivative
void TCurveBase::derivative(const Math::Vector2 & xy, Math::Vector2 & dxdy) const
{
double abserr;
struct curve_gsl_params_s params;
gsl_function gsl_func;
gsl_func.params = ¶ms;
params.c = this;
params.x = xy.x();
params.y = xy.y();
gsl_func.function = gsl_func_sagitta_x;
gsl_deriv_central(&gsl_func, xy.x(), 1e-6, &dxdy.x(), &abserr);
gsl_func.function = gsl_func_sagitta_y;
gsl_deriv_central(&gsl_func, xy.y(), 1e-6, &dxdy.y(), &abserr);
}
示例11: inside
bool Polygon::inside(const math::Vector2 &p) const
{
unsigned int s = _vertices.size();
if (s < 3)
return false;
unsigned int count = 0;
const math::Vector2 *w = &_vertices[s - 1];
// FIXME optimize
for (unsigned int i = 0; i < s; i++)
{
const math::Vector2 *v = &_vertices[i];
// Algorithm from http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/
if ((((v->y() <= p.y()) && (p.y() < w->y())) || ((w->y() <= p.y()) && (p.y() < v->y()))) &&
(p.x() < (w->x() - v->x()) * (p.y() - v->y()) / (w->y() - v->y()) + v->x()))
count++;
w = v;
}
return (count & 1) != 0;
}
示例12: switch
void TLens::draw_2d_edge(TRenderer &r, const TSurface &left, double l_y,
const TSurface &right, double r_y, LensEdge type,
const TElement *ref) const
{
const Math::Vector3 l3(0., l_y, left.get_curve()->sagitta(Math::Vector2(0., l_y)));
const Math::Vector2 l2(left.get_transform_to(ref).transform(l3).project_zy());
const Math::Vector3 r3(0., r_y, right.get_curve()->sagitta(Math::Vector2(0., r_y)));
const Math::Vector2 r2(right.get_transform_to(ref).transform(r3).project_zy());
switch (type)
{
case StraightEdge: {
if (fabs(l2.y() - r2.y()) > 1e-6)
{
double m;
if (fabs(l2.y()) > fabs(r2.y()))
{
m = l2.y();
r.draw_segment(Math::VectorPair2(r2.x(), m, r2.x(), r2.y()), left.get_color(r));
}
else
{
m = r2.y();
r.draw_segment(Math::VectorPair2(l2.x(), m, l2.x(), l2.y()), left.get_color(r));
}
r.draw_segment(Math::VectorPair2(l2.x(), m, r2.x(), m), left.get_color(r));
break;
}
}
case SlopeEdge:
r.draw_segment(l2, r2, left.get_color(r));
break;
}
}
示例13: aspectRatioScale
constexpr static Math::Matrix4<T> aspectRatioScale(const Math::Vector2<T>& scale) {
return Math::Matrix4<T>::scaling({scale.x(), scale.y(), 1.0f});
}
示例14: inside
bool TRingBase::inside(const Math::Vector2 &point) const
{
double d = Math::square(point.x()) + Math::square(point.y());
return d <= Math::square(_radius) && d >= Math::square(_hole_radius);
}
示例15: get_outter_radius
double EllipseBase::get_outter_radius(const math::Vector2 &dir) const
{
return _xr > _yr
? sqrt(math::square(_yr) / (1. - _e2 * math::square(dir.x())))
: sqrt(math::square(_xr) / (1. - _e2 * math::square(dir.y())));
}