OpenSiv3D  v0.6.5
C++20 framework for creative coding
s3d::Point Struct Reference

2 次元のベクトル(整数) More...

#include <Point.hpp>

Public Types

using value_type = int32
 ベクトルの要素の型 More...
 

Public Member Functions

SIV3D_NODISCARD_CXX20 Point ()=default
 
SIV3D_NODISCARD_CXX20 Point (const Point &)=default
 
constexpr SIV3D_NODISCARD_CXX20 Point (value_type _x, value_type _y) noexcept
 
template<class IntegerX , class IntegerY , std::enable_if_t< std::conjunction_v< std::is_integral< IntegerX >, std::is_integral< IntegerY >>> * = nullptr>
constexpr SIV3D_NODISCARD_CXX20 Point (IntegerX _x, IntegerY _y) noexcept
 
template<class X , class Y , std::enable_if_t<(not std::is_integral_v< X >)||(not std::is_integral_v< Y >)> * = nullptr>
constexpr Point (X _x, Y _y) noexcept=delete
 
constexpr value_type elem (size_t index) const noexcept
 
value_typegetPointer () noexcept
 
const value_typegetPointer () const noexcept
 
constexpr Pointoperator= (const Point &)=default
 
constexpr Point operator+ () const noexcept
 
constexpr Point operator- () const noexcept
 
constexpr Point operator+ (Point p) const noexcept
 
constexpr Point operator- (Point p) const noexcept
 
template<class Type >
constexpr Vector2D< Type > operator+ (Vector2D< Type > v) const noexcept
 
template<class Type >
constexpr Vector2D< Type > operator- (Vector2D< Type > v) const noexcept
 
constexpr Point operator* (int32 s) const noexcept
 
constexpr Float2 operator* (float s) const noexcept
 
constexpr Vec2 operator* (double s) const noexcept
 
constexpr Point operator* (Point p) const noexcept
 
template<class Type >
constexpr Vector2D< Type > operator* (Vector2D< Type > v) const noexcept
 
constexpr Point operator/ (int32 s) const noexcept
 
constexpr Float2 operator/ (float s) const noexcept
 
constexpr Vec2 operator/ (double s) const noexcept
 
constexpr Point operator/ (Point p) const noexcept
 
template<class Type >
constexpr Vector2D< Type > operator/ (Vector2D< Type > v) const noexcept
 
constexpr Pointoperator+= (Point p) noexcept
 
constexpr Pointoperator-= (Point p) noexcept
 
constexpr Pointoperator*= (int32 s) noexcept
 
constexpr Pointoperator/= (int32 s) noexcept
 
constexpr bool isZero () const noexcept
 
constexpr value_type minComponent () const noexcept
 
constexpr value_type maxComponent () const noexcept
 
constexpr void clear () noexcept
 
constexpr Pointset (int32 _x, int32 _y) noexcept
 
constexpr Pointset (Point p) noexcept
 
constexpr Point movedBy (int32 _x, int32 _y) const noexcept
 
constexpr Point movedBy (Point p) const noexcept
 
template<class Type >
constexpr Vector2D< Type > movedBy (Vector2D< Type > v) const noexcept
 
constexpr PointmoveBy (int32 _x, int32 _y) noexcept
 
constexpr PointmoveBy (Point p) noexcept
 
template<class Type = double>
constexpr Type horizontalAspectRatio () const noexcept
 
template<class Type = double>
Type length () const noexcept
 ベクトルの大きさ(長さ)を返します。 More...
 
template<class Type = double>
constexpr Type lengthSq () const noexcept
 ベクトルの大きさ(長さ)の二乗を返します。 More...
 
constexpr int32 manhattanLength () const noexcept
 原点からこの座標までのマンハッタン距離を返します。 More...
 
constexpr int32 manhattanDistanceFrom (int32 _x, int32 _y) const noexcept
 別の位置ベクトルからのマンハッタン距離を返します。 More...
 
constexpr int32 manhattanDistanceFrom (Point p) const noexcept
 別の座標からのマンハッタン距離を返します。 More...
 
double distanceFrom (double _x, double _y) const noexcept
 別の座標からの距離を返します。 More...
 
double distanceFrom (Point p) const noexcept
 別の座標からの距離を返します。 More...
 
template<class Type >
double distanceFrom (Vector2D< Type > p) const noexcept
 別の座標からの距離を返します。 More...
 
constexpr double distanceFromSq (double _x, double _y) const noexcept
 別の座標からの距離の二乗を返します。 More...
 
constexpr double distanceFromSq (Point p) const noexcept
 別の座標からの距離の二乗を返します。 More...
 
template<class Type >
constexpr double distanceFromSq (Vector2D< Type > p) const noexcept
 別の座標からの距離の二乗を返します。 More...
 
constexpr int32 area () const noexcept
 幅 x, 高さ y の長方形の面積を返します。 More...
 
template<class Type = double>
Type getAngle () const noexcept
 
template<class Type >
Type getAngle (Vector2D< Type > other) const noexcept
 
constexpr Point getPerpendicularCW () const noexcept
 
constexpr Point getPerpendicularCCW () const noexcept
 
template<class Type = double>
constexpr Vector2D< Type > getMidpoint (Point other) const noexcept
 
template<class Type >
constexpr Vector2D< Type > getMidpoint (Vector2D< Type > other) const noexcept
 
template<class T , class U >
auto getPointByAngleAndDistance (T angle, U distance) const noexcept
 
template<class Type = double>
constexpr Vector2D< Type > lerp (Point other, double f) const noexcept
 
template<class Type >
constexpr Vector2D< Type > lerp (Vector2D< Type > other, double f) const noexcept
 
Circle asCircle (double r) const noexcept
 
template<class Shape2DType >
constexpr bool intersects (const Shape2DType &other) const
 
bool leftClicked () const noexcept
 
bool leftPressed () const noexcept
 
bool leftReleased () const noexcept
 
bool rightClicked () const noexcept
 
bool rightPressed () const noexcept
 
bool rightReleased () const noexcept
 
bool mouseOver () const noexcept
 
const Pointpaint (Image &dst, const Color &color) const
 
const Pointoverwrite (Image &dst, const Color &color) const
 
size_t hash () const noexcept
 
constexpr Point xx () const noexcept
 Point{ x, x } を返します。 More...
 
constexpr Point xy () const noexcept
 Point{ x, y } を返します。 More...
 
constexpr Point yx () const noexcept
 Point{ y x } を返します。 More...
 
constexpr Point yy () const noexcept
 Point{ y, y } を返します。 More...
 
constexpr Point x0 () const noexcept
 Point{ x, 0 } を返します。 More...
 
constexpr Point y0 () const noexcept
 Point{ y, 0 } を返します。 More...
 

Static Public Member Functions

static constexpr Point Zero () noexcept
 Point{ 0, 0 } を返します。 More...
 
static constexpr Point One () noexcept
 Point{ 1, 1 } を返します。 More...
 
static constexpr Point All (value_type value=1) noexcept
 Point{ value, value } を返します。 More...
 
static constexpr Point UnitX () noexcept
 Point{ 1, 0 } を返します。 More...
 
static constexpr Point UnitY () noexcept
 Point{ 0, 1 } を返します。 More...
 
static constexpr Point Left (value_type length=1) noexcept
 Point{ -length, 0 } を返します。 More...
 
static constexpr Point Right (value_type length=1) noexcept
 Point{ length, 0 } を返します。 More...
 
static constexpr Point Up (value_type length=1) noexcept
 Point{ 0, -length } を返します。 More...
 
static constexpr Point Down (value_type length=1) noexcept
 Point{ 0, length } を返します。 More...
 

Public Attributes

value_type x
 ベクトルの X 成分 More...
 
value_type y
 ベクトルの Y 成分 More...
 

Static Public Attributes

static constexpr size_t Dimension = 2
 ベクトルの次元数 More...
 

Friends

constexpr friend Point operator* (int32 s, Point p) noexcept
 
constexpr friend Vector2D< float > operator* (float s, Point p) noexcept
 
constexpr friend Vector2D< double > operator* (double s, Point p) noexcept
 
constexpr friend bool operator== (Point lhs, Point rhs) noexcept
 
constexpr friend bool operator!= (Point lhs, Point rhs) noexcept
 
template<class CharType >
std::basic_ostream< CharType > & operator<< (std::basic_ostream< CharType > &output, const Point &value)
 
template<class CharType >
std::basic_istream< CharType > & operator>> (std::basic_istream< CharType > &input, Point &value)
 
void Formatter (FormatData &formatData, const Point &value)
 

Detailed Description

2 次元のベクトル(整数)

Member Typedef Documentation

◆ value_type

ベクトルの要素の型

Constructor & Destructor Documentation

◆ Point() [1/5]

SIV3D_NODISCARD_CXX20 s3d::Point::Point ( )
default

◆ Point() [2/5]

SIV3D_NODISCARD_CXX20 s3d::Point::Point ( const Point )
default

◆ Point() [3/5]

constexpr SIV3D_NODISCARD_CXX20 s3d::Point::Point ( value_type  _x,
value_type  _y 
)
constexprnoexcept

◆ Point() [4/5]

template<class IntegerX , class IntegerY , std::enable_if_t< std::conjunction_v< std::is_integral< IntegerX >, std::is_integral< IntegerY >>> * = nullptr>
constexpr SIV3D_NODISCARD_CXX20 s3d::Point::Point ( IntegerX  _x,
IntegerY  _y 
)
constexprnoexcept

◆ Point() [5/5]

template<class X , class Y , std::enable_if_t<(not std::is_integral_v< X >)||(not std::is_integral_v< Y >)> * = nullptr>
constexpr s3d::Point::Point ( _x,
_y 
)
constexprdeletenoexcept

Member Function Documentation

◆ All()

static constexpr Point s3d::Point::All ( value_type  value = 1)
staticconstexprnoexcept

Point{ value, value } を返します。

Parameters
value
Returns
Point{ value, value }

◆ area()

constexpr int32 s3d::Point::area ( ) const
constexprnoexcept

幅 x, 高さ y の長方形の面積を返します。

Returns
幅 x, 高さ y の長方形の面積

◆ asCircle()

Circle s3d::Point::asCircle ( double  r) const
noexcept

◆ clear()

constexpr void s3d::Point::clear ( )
constexprnoexcept

◆ distanceFrom() [1/3]

double s3d::Point::distanceFrom ( double  _x,
double  _y 
) const
noexcept

別の座標からの距離を返します。

Parameters
_x別の座標の X 成分
_y別の座標の Y 成分
Returns
別の座標からの距離

◆ distanceFrom() [2/3]

double s3d::Point::distanceFrom ( Point  p) const
noexcept

別の座標からの距離を返します。

Parameters
p別の座標
Returns
別の座標からの距離

◆ distanceFrom() [3/3]

template<class Type >
double s3d::Point::distanceFrom ( Vector2D< Type >  p) const
noexcept

別の座標からの距離を返します。

Template Parameters
Type別の座標の成分の型
Parameters
p別の座標
Returns
別の座標からの距離

◆ distanceFromSq() [1/3]

constexpr double s3d::Point::distanceFromSq ( double  _x,
double  _y 
) const
constexprnoexcept

別の座標からの距離の二乗を返します。

Parameters
_x別の座標の X 成分
_y別の座標の Y 成分
Remarks
平方根を計算しないため distanceFrom() より高速です。
Returns
別の座標からの距離の二乗

◆ distanceFromSq() [2/3]

constexpr double s3d::Point::distanceFromSq ( Point  p) const
constexprnoexcept

別の座標からの距離の二乗を返します。

Parameters
p別の座標
Remarks
平方根を計算しないため distanceFrom() より高速です。
Returns
別の座標からの距離の二乗

◆ distanceFromSq() [3/3]

template<class Type >
constexpr double s3d::Point::distanceFromSq ( Vector2D< Type >  p) const
constexprnoexcept

別の座標からの距離の二乗を返します。

Template Parameters
Type別の座標の成分の型
Parameters
p別の座標
Remarks
平方根を計算しないため distanceFrom() より高速です。
Returns
別の座標からの距離の二乗

◆ Down()

static constexpr Point s3d::Point::Down ( value_type  length = 1)
staticconstexprnoexcept

Point{ 0, length } を返します。

Parameters
length
Returns
Point{ 0, length }

◆ elem()

constexpr value_type s3d::Point::elem ( size_t  index) const
constexprnoexcept

◆ getAngle() [1/2]

template<class Type = double>
Type s3d::Point::getAngle ( ) const
noexcept

◆ getAngle() [2/2]

template<class Type >
Type s3d::Point::getAngle ( Vector2D< Type >  other) const
noexcept

◆ getMidpoint() [1/2]

template<class Type = double>
constexpr Vector2D<Type> s3d::Point::getMidpoint ( Point  other) const
constexprnoexcept

◆ getMidpoint() [2/2]

template<class Type >
constexpr Vector2D<Type> s3d::Point::getMidpoint ( Vector2D< Type >  other) const
constexprnoexcept

◆ getPerpendicularCCW()

constexpr Point s3d::Point::getPerpendicularCCW ( ) const
constexprnoexcept

◆ getPerpendicularCW()

constexpr Point s3d::Point::getPerpendicularCW ( ) const
constexprnoexcept

◆ getPointByAngleAndDistance()

template<class T , class U >
auto s3d::Point::getPointByAngleAndDistance ( angle,
distance 
) const
noexcept

◆ getPointer() [1/2]

const value_type* s3d::Point::getPointer ( ) const
noexcept

◆ getPointer() [2/2]

value_type* s3d::Point::getPointer ( )
noexcept

◆ hash()

size_t s3d::Point::hash ( ) const
noexcept

◆ horizontalAspectRatio()

template<class Type = double>
constexpr Type s3d::Point::horizontalAspectRatio ( ) const
constexprnoexcept

◆ intersects()

template<class Shape2DType >
constexpr bool s3d::Point::intersects ( const Shape2DType &  other) const
constexpr

◆ isZero()

constexpr bool s3d::Point::isZero ( ) const
constexprnoexcept

◆ Left()

static constexpr Point s3d::Point::Left ( value_type  length = 1)
staticconstexprnoexcept

Point{ -length, 0 } を返します。

Parameters
length
Returns
Point{ -length, 0 }

◆ leftClicked()

bool s3d::Point::leftClicked ( ) const
noexcept

◆ leftPressed()

bool s3d::Point::leftPressed ( ) const
noexcept

◆ leftReleased()

bool s3d::Point::leftReleased ( ) const
noexcept

◆ length()

template<class Type = double>
Type s3d::Point::length ( ) const
noexcept

ベクトルの大きさ(長さ)を返します。

Template Parameters
Type結果の型
Returns
ベクトルの大きさ(長さ)

◆ lengthSq()

template<class Type = double>
constexpr Type s3d::Point::lengthSq ( ) const
constexprnoexcept

ベクトルの大きさ(長さ)の二乗を返します。

Template Parameters
Type結果の型
Remarks
平方根を計算しないため length() より高速です。
Returns
ベクトルの大きさ(長さ)の二乗

◆ lerp() [1/2]

template<class Type = double>
constexpr Vector2D<Type> s3d::Point::lerp ( Point  other,
double  f 
) const
constexprnoexcept

◆ lerp() [2/2]

template<class Type >
constexpr Vector2D<Type> s3d::Point::lerp ( Vector2D< Type >  other,
double  f 
) const
constexprnoexcept

◆ manhattanDistanceFrom() [1/2]

constexpr int32 s3d::Point::manhattanDistanceFrom ( int32  _x,
int32  _y 
) const
constexprnoexcept

別の位置ベクトルからのマンハッタン距離を返します。

Parameters
_x別の座標の X 成分
_y別の座標の Y 成分
Returns
別の座標からのマンハッタン距離

◆ manhattanDistanceFrom() [2/2]

constexpr int32 s3d::Point::manhattanDistanceFrom ( Point  p) const
constexprnoexcept

別の座標からのマンハッタン距離を返します。

Parameters
p別の座標
Returns
別の座標からのマンハッタン距離

◆ manhattanLength()

constexpr int32 s3d::Point::manhattanLength ( ) const
constexprnoexcept

原点からこの座標までのマンハッタン距離を返します。

Returns
原点からのマンハッタン距離

◆ maxComponent()

constexpr value_type s3d::Point::maxComponent ( ) const
constexprnoexcept

◆ minComponent()

constexpr value_type s3d::Point::minComponent ( ) const
constexprnoexcept

◆ mouseOver()

bool s3d::Point::mouseOver ( ) const
noexcept

◆ moveBy() [1/2]

constexpr Point& s3d::Point::moveBy ( int32  _x,
int32  _y 
)
constexprnoexcept

◆ moveBy() [2/2]

constexpr Point& s3d::Point::moveBy ( Point  p)
constexprnoexcept

◆ movedBy() [1/3]

constexpr Point s3d::Point::movedBy ( int32  _x,
int32  _y 
) const
constexprnoexcept

◆ movedBy() [2/3]

constexpr Point s3d::Point::movedBy ( Point  p) const
constexprnoexcept

◆ movedBy() [3/3]

template<class Type >
constexpr Vector2D<Type> s3d::Point::movedBy ( Vector2D< Type >  v) const
constexprnoexcept

◆ One()

static constexpr Point s3d::Point::One ( )
staticconstexprnoexcept

Point{ 1, 1 } を返します。

Returns
Point{ 1, 1 }

◆ operator*() [1/5]

constexpr Vec2 s3d::Point::operator* ( double  s) const
constexprnoexcept

◆ operator*() [2/5]

constexpr Float2 s3d::Point::operator* ( float  s) const
constexprnoexcept

◆ operator*() [3/5]

constexpr Point s3d::Point::operator* ( int32  s) const
constexprnoexcept

◆ operator*() [4/5]

constexpr Point s3d::Point::operator* ( Point  p) const
constexprnoexcept

◆ operator*() [5/5]

template<class Type >
constexpr Vector2D<Type> s3d::Point::operator* ( Vector2D< Type >  v) const
constexprnoexcept

◆ operator*=()

constexpr Point& s3d::Point::operator*= ( int32  s)
constexprnoexcept

◆ operator+() [1/3]

constexpr Point s3d::Point::operator+ ( ) const
constexprnoexcept

◆ operator+() [2/3]

constexpr Point s3d::Point::operator+ ( Point  p) const
constexprnoexcept

◆ operator+() [3/3]

template<class Type >
constexpr Vector2D<Type> s3d::Point::operator+ ( Vector2D< Type >  v) const
constexprnoexcept

◆ operator+=()

constexpr Point& s3d::Point::operator+= ( Point  p)
constexprnoexcept

◆ operator-() [1/3]

constexpr Point s3d::Point::operator- ( ) const
constexprnoexcept

◆ operator-() [2/3]

constexpr Point s3d::Point::operator- ( Point  p) const
constexprnoexcept

◆ operator-() [3/3]

template<class Type >
constexpr Vector2D<Type> s3d::Point::operator- ( Vector2D< Type >  v) const
constexprnoexcept

◆ operator-=()

constexpr Point& s3d::Point::operator-= ( Point  p)
constexprnoexcept

◆ operator/() [1/5]

constexpr Vec2 s3d::Point::operator/ ( double  s) const
constexprnoexcept

◆ operator/() [2/5]

constexpr Float2 s3d::Point::operator/ ( float  s) const
constexprnoexcept

◆ operator/() [3/5]

constexpr Point s3d::Point::operator/ ( int32  s) const
constexprnoexcept

◆ operator/() [4/5]

constexpr Point s3d::Point::operator/ ( Point  p) const
constexprnoexcept

◆ operator/() [5/5]

template<class Type >
constexpr Vector2D<Type> s3d::Point::operator/ ( Vector2D< Type >  v) const
constexprnoexcept

◆ operator/=()

constexpr Point& s3d::Point::operator/= ( int32  s)
constexprnoexcept

◆ operator=()

constexpr Point& s3d::Point::operator= ( const Point )
constexprdefault

◆ overwrite()

const Point& s3d::Point::overwrite ( Image dst,
const Color color 
) const

◆ paint()

const Point& s3d::Point::paint ( Image dst,
const Color color 
) const

◆ Right()

static constexpr Point s3d::Point::Right ( value_type  length = 1)
staticconstexprnoexcept

Point{ length, 0 } を返します。

Parameters
length
Returns
Point{ length, 0 }

◆ rightClicked()

bool s3d::Point::rightClicked ( ) const
noexcept

◆ rightPressed()

bool s3d::Point::rightPressed ( ) const
noexcept

◆ rightReleased()

bool s3d::Point::rightReleased ( ) const
noexcept

◆ set() [1/2]

constexpr Point& s3d::Point::set ( int32  _x,
int32  _y 
)
constexprnoexcept

◆ set() [2/2]

constexpr Point& s3d::Point::set ( Point  p)
constexprnoexcept

◆ UnitX()

static constexpr Point s3d::Point::UnitX ( )
staticconstexprnoexcept

Point{ 1, 0 } を返します。

Returns
Point{ 1, 0 }

◆ UnitY()

static constexpr Point s3d::Point::UnitY ( )
staticconstexprnoexcept

Point{ 0, 1 } を返します。

Returns
Point{ 0, 1 }

◆ Up()

static constexpr Point s3d::Point::Up ( value_type  length = 1)
staticconstexprnoexcept

Point{ 0, -length } を返します。

Parameters
length
Returns
Point{ 0, -length }

◆ x0()

constexpr Point s3d::Point::x0 ( ) const
constexprnoexcept

Point{ x, 0 } を返します。

Returns
Point{ x, 0 }

◆ xx()

constexpr Point s3d::Point::xx ( ) const
constexprnoexcept

Point{ x, x } を返します。

Returns
Point{ x, x }

◆ xy()

constexpr Point s3d::Point::xy ( ) const
constexprnoexcept

Point{ x, y } を返します。

Returns
Point{ x, y }

◆ y0()

constexpr Point s3d::Point::y0 ( ) const
constexprnoexcept

Point{ y, 0 } を返します。

Returns
Point{ y, 0 }

◆ yx()

constexpr Point s3d::Point::yx ( ) const
constexprnoexcept

Point{ y x } を返します。

Returns
Point{ y, x }

◆ yy()

constexpr Point s3d::Point::yy ( ) const
constexprnoexcept

Point{ y, y } を返します。

Returns
Point{ y, y }

◆ Zero()

static constexpr Point s3d::Point::Zero ( )
staticconstexprnoexcept

Point{ 0, 0 } を返します。

Returns
Point{ 0, 0 }

Friends And Related Function Documentation

◆ Formatter

void Formatter ( FormatData formatData,
const Point value 
)
friend

◆ operator!=

constexpr friend bool operator!= ( Point  lhs,
Point  rhs 
)
friend

◆ operator* [1/3]

constexpr friend Vector2D<double> operator* ( double  s,
Point  p 
)
friend

◆ operator* [2/3]

constexpr friend Vector2D<float> operator* ( float  s,
Point  p 
)
friend

◆ operator* [3/3]

constexpr friend Point operator* ( int32  s,
Point  p 
)
friend

◆ operator<<

template<class CharType >
std::basic_ostream<CharType>& operator<< ( std::basic_ostream< CharType > &  output,
const Point value 
)
friend

◆ operator==

constexpr friend bool operator== ( Point  lhs,
Point  rhs 
)
friend

◆ operator>>

template<class CharType >
std::basic_istream<CharType>& operator>> ( std::basic_istream< CharType > &  input,
Point value 
)
friend

Member Data Documentation

◆ Dimension

constexpr size_t s3d::Point::Dimension = 2
staticconstexpr

ベクトルの次元数

◆ x

value_type s3d::Point::x

ベクトルの X 成分

◆ y

value_type s3d::Point::y

ベクトルの Y 成分


The documentation for this struct was generated from the following file: