Maria GDK 5.0.0.738
Documentation of native code in develop branch
Loading...
Searching...
No Matches
STK Namespace Reference

Classes

class  AngleOpenGLContext
 
class  AngleOpenGLFunctions
 
class  AngularFilterClass
 
class  AnimationController
 
class  AssetDataProvider
 
class  AssimpProgressHandler
 
class  AxisModel
 
class  B3DMParser
 
class  BillboardRenderItem
 
class  BlendFunc
 
class  Bone
 
class  Box2
 
struct  BulletProxy
 
class  Camera
 
class  CatmullRom
 Nonstatic and faster version of the Catmull-Rom spline used for smoothing. More...
 
class  Circle
 
class  Clipper
 
class  CollisionObject
 
class  Color4
 
class  Color4d
 
class  Color4f
 
class  Color4i
 
class  Color4ub
 
class  CommandLineOption
 
class  CommandLineParser
 
class  CSMSceneRenderer
 
class  CubeMap
 
struct  DXT1Block
 
struct  DXT3Block
 
struct  DXT5Block
 
class  DynamicsWorld
 
class  EllipseRender2D
 
struct  enable_if_safe_cast
 
class  FBODepthTexture
 
class  FBOTexture
 
class  FileLogger
 
class  FilePath
 
class  FilePathResolver
 
class  FilterClass
 
class  FixedScaleRenderItem
 
class  Font
 
class  FontManager
 
class  FrameBufferFX
 
class  GLState
 
class  GraphicsModel
 
class  GraphicsModelGroup
 
class  GraphicsModelInstance
 
class  GraphicsModelLoader
 
class  GraphicsModelManager
 
class  GraphicsRender2D
 
class  GridIndex
 
class  IconRenderItem
 
class  ILogger
 
class  Image
 
class  ImageDdsIO
 
class  ImageIO
 
class  ImageJpegIO
 
class  ImagePngIO
 
class  ImageStbIO
 
class  ImageTransform
 
struct  IndexTriangle
 
class  Keyframe
 
class  KeyframeNodeAnimation
 
class  Light
 
class  LinearFilterClass
 
class  LinearRegression
 
class  LineRenderer
 
class  LineSimplification
 
class  LODGraphicsModel
 
class  LogStream
 
class  MarkerObject
 
class  Material
 
class  MaterialLoader
 
class  MaterialMeshGroup
 
class  Matrix4x4
 
class  Mesh
 
class  MeshCollisionObject
 
class  MeshColors
 
class  MeshGraphicsModel
 
class  MeshNode
 
class  MeshRender
 
class  MeshShadingColors
 
class  MeshSimpleColor
 
class  NativeModelReader
 
class  NativeModelWriter
 
class  OpenGLContext
 
class  OpenGLFunctions
 
class  OrientedBoundingBox2
 
class  PerformanceGraphs
 
class  PidControlClass
 
class  Polygon
 
class  PolygonRender2D
 
class  PolylineRender2D
 
class  PrecomputedScattering
 
class  ProgressHandler
 
class  Quaternion
 
class  RenderItem2D
 
struct  safe_type_cast
 
class  SafeTextureBinder
 
class  SafeTextureBinding
 
class  ScaleImage
 
class  SceneRenderer
 
class  Screen
 
class  ScreenGraph
 
class  ShaderProgram
 
class  ShaderProgramManager
 
class  ShaderResources
 
class  SharedCounter
 
class  Tab1
 
class  Tab2
 
class  Tab3
 
class  TextItem
 
class  TextLabel3D
 
class  TextRenderItem
 
class  TextRenderItemSDF
 
class  Texture
 
class  Texture2D
 
class  TextureFont
 
class  TextureFontSDF
 
class  TextureLoader
 
class  TextureManager
 
class  TextureTransform
 
class  TimerFunc
 
class  Transform2
 
class  Uniform
 
class  UniformPoissonDiscSampler
 
class  Vector2
 
class  Vector3
 
class  Vector4
 
class  VertexBuffer
 
class  VertexBuffer2D
 
class  VertexBufferManager2D
 
class  VertexBufferP
 
class  VertexBufferPC
 
class  VertexBufferPN
 
class  VertexBufferPNT
 
class  VertexBufferPNTWI
 
class  VertexBufferPNWI
 
class  VertexBufferPT
 
struct  VertexPC
 
struct  VertexPN
 
struct  VertexPNT
 
struct  VertexPNTWI
 
struct  VertexPNWI
 
struct  VertexPT
 
class  Viewport
 

Typedefs

typedef unsigned int RGBA
 
template<typename From , typename To >
using enable_if_safe_cast_t = typename enable_if_safe_cast< From, To >::type
 
typedef AngularFilterClass< float > AngularFilterf
 
typedef AngularFilterClass< double > AngularFilter
 
using CatmullRomf = CatmullRom< float >
 
using CatmullRomd = CatmullRom< double >
 
typedef FilterClass< float > Filterf
 
typedef FilterClass< double > Filter
 
typedef LinearFilterClass< float > LinearFilterf
 
typedef LinearFilterClass< double > LinearFilter
 
using Matrix4x4d = Matrix4x4< double >
 
using Matrix4x4f = Matrix4x4< float >
 
typedef OrientedBoundingBox2< float > OrientedBoundingBox2f
 
typedef OrientedBoundingBox2< double > OrientedBoundingBox2d
 
typedef PidControlClass< float > PidControlf
 
typedef PidControlClass< double > PidControl
 
typedef Polygon< Vector2fPolygon2f
 
typedef Polygon< Vector2dPolygon2d
 
typedef Polygon< Vector3fPolygon3f
 
typedef Polygon< Vector3dPolygon3d
 
typedef std::vector< Vector3dPointVector
 
typedef std::shared_ptr< std::vector< Vector3d > > SharedPointVector
 
using Quaterniond = Quaternion< double >
 
using Quaternionf = Quaternion< float >
 
typedef Transform2< float > Transform2f
 
typedef Transform2< double > Transform2d
 
using Vector2d = Vector2< double >
 
using Vector2f = Vector2< float >
 
using Vector3f = Vector3< float >
 
using Vector3d = Vector3< double >
 
using Vector4f = Vector4< float >
 
using Vector4d = Vector4< double >
 

Enumerations

enum  LogLevel {
  LOG_DEBUG = 0 , LOG_INFO , LOG_WARNING , LOG_ERROR ,
  LOG_FATAL
}
 
enum class  ResampMethod {
  NEAREST = 0 , BOX_NEAREST , FILTER , LINEAR ,
  QUADRATIC , CUBIC , LANCZOS , MITCHELL ,
  MAX_COUNT
}
 
enum class  FontStyle { Regular , Bold , Italic , BoldItalic }
 
enum  RenderMask { OpaqueMask = 0x0001 , TransparentMask = 0x0002 }
 
enum class  StencilMode {
  NONE , WRITE_STENCIL , WRITE_STENCIL_COLOR , TEST_EQ ,
  TEST_NEQ
}
 
enum class  TextHAlignment { Left , Center , Right }
 
enum class  TextVAlignment { Bottom , Center , Top }
 

Functions

bool getBinaryDir (std::string &dir)
 
bool getInstallationDir (std::string &dir)
 
bool getApplicationDataDir (std::string &dir)
 
bool getUserDataDir (std::string &dir)
 
void initApplication ()
 
void initApplication (const std::vector< std::string > &args)
 
void initApplication (const std::vector< std::string > &args, STK::CommandLineParser &parser)
 
LogStream logDebug (const std::string &module="")
 
LogStream logInfo (const std::string &module="")
 
LogStream logWarning (const std::string &module="")
 
LogStream logError (const std::string &module="")
 
LogStreamendl (LogStream &ls)
 
RGBA toRGBA (int r, int g, int b, int a=255)
 
RGBA fromARGB (RGBA val)
 
RGBA floatToRGBA (float r, float g, float b, float a=1.0)
 
RGBA toARGB (int r, int g, int b, int a=255)
 
RGBA floatToARGB (float r, float g, float b, float a=1.0)
 
RGBA multiplyAlpha (RGBA rgba, float a)
 
void RGBAToFloat (RGBA rgba, float &r, float &g, float &b, float &a)
 
char toLower (const char c)
 
char toUpper (const char c)
 
void splitString (const std::string &str, char delim, std::vector< std::string > &strlist)
 
std::string joinString (const std::vector< std::string > &strList, const std::string &delim)
 
void toLowerCaseInline (std::string &str)
 
void toUpperCaseInline (std::string &str)
 
std::string toLowerCase (const std::string &str)
 
std::string toUpperCase (const std::string &str)
 
bool strEndsWith (const std::string &str, const std::string &suffix, bool caseSensitive=false)
 
bool strBeginsWith (const std::string &str, const std::string &prefix, bool caseSensitive=false)
 
std::string replaceAll (const std::string &str, const std::string &from, const std::string &to)
 
std::wstring s2ws (const std::string &str)
 
std::string ws2s (const std::wstring &wstr)
 
std::u32string utf8ToUtf32 (std::string const &utf8)
 
void unreachable ()
 
std::FILE * fopen (std::string_view filename, std::string_view mode)
 
std::string createUUID ()
 
bool compressDXTC (const Image &src, Image &dst, Image::Format fmt)
 
bool decompressDXTC (const Image &src, Image &dst, Image::Format=Image::RGBA_32)
 
bool decompressDXT1 (const Image &src, Image &dst, Image::Format=Image::RGBA_32)
 
bool decompressDXT3 (const Image &src, Image &dst, Image::Format=Image::RGBA_32)
 
bool decompressDXT5 (const Image &src, Image &dst, Image::Format=Image::RGBA_32)
 
void calcNormalVector (const STK::Image &img, int x, int y, double dx, double dy, double &nx, double &ny, double &nz)
 
int singles2halfp (void *target, void *source, int numel)
 
int doubles2halfp (void *target, void *source, int numel)
 
int halfp2singles (void *target, void *source, int numel)
 
int halfp2doubles (void *target, void *source, int numel)
 
int ilog2 (int n)
 Calculate the base two logarithm of an integer.
 
int nearestPow2 (int val)
 Calculate the nearest power of 2 of the given integer.
 
bool convHull2D (const std::vector< STK::Vector3d > &pts, std::vector< STK::Vector3d > &out_pts)
 Calculate the 2D convex hull of a point set.
 
template<class Type >
bool distanceLinePoint (const STK::Vector3< Type > &p1, const STK::Vector3< Type > &p2, const STK::Vector3< Type > &p, Type &d)
 
template<class T >
STK::Vector2< T > centroid (const std::vector< STK::Vector2< T > > &pts)
 
double normalizeAngleDegrees (double angle)
 Normalize the given angle to the interval 0 - 360.
 
template<class T >
getMinXValue (const std::vector< STK::Vector2< T > > &pts)
 
template<class T >
double getMaxXValue (const std::vector< STK::Vector2< T > > &pts)
 
template<class T >
double getMinYValue (const std::vector< STK::Vector2< T > > &pts)
 
template<class T >
double getMaxYValue (const std::vector< STK::Vector2< T > > &pts)
 
template<class Type >
bool rayTriangleIntersection (const STK::Vector3< Type > &rayOrigin, const STK::Vector3< Type > &rayVector, const STK::Vector3< Type > &vertex0, const STK::Vector3< Type > &vertex1, const STK::Vector3< Type > &vertex2, STK::Vector3< Type > &outIntersectionPoint)
 
template<class Type >
bool raySphereIntersection (const STK::Vector3< Type > &rayOrigin, const STK::Vector3< Type > &rayVector, const STK::Vector3< Type > &sphCenter, Type sphRadius, Type &t)
 
template<class Type >
bool rayPlaneIntersection (const STK::Vector3< Type > &planePoint, const STK::Vector3< Type > &planeNormal, const STK::Vector3< Type > &linePoint, const STK::Vector3< Type > &lineDirection, STK::Vector3< Type > &intersection)
 
template<class Type >
Type closestDistanceBetweenLines (const STK::Vector3< Type > &L1P0, const STK::Vector3< Type > &L1Dir, const STK::Vector3< Type > &L2P0, const STK::Vector3< Type > &L2Dir, STK::Vector3< Type > &L1P, STK::Vector3< Type > &L2P)
 
template<class Type >
bool convHull2D (const std::vector< STK::Vector3< Type > > &pts, std::vector< STK::Vector3< Type > > &hull)
 
template<typename Type >
std::optional< STK::Vector2< Type > > segmentIntersection (const STK::Vector2< Type > &S1Start, const STK::Vector2< Type > &S1End, const STK::Vector2< Type > &S2Start, const STK::Vector2< Type > &S2End)
 Find the intersection point between two segments in 2d. Algorithm from: https://stackoverflow.com/a/565282.
 
double calcEccentricAnomalyFromAngle (const double angle, const double a, const double b, const double tolerance=0.000001)
 
std::vector< STK::SharedPointVector > polyClip (STK::SharedPointVector poly, double xMin, double yMin, double xMax, double yMax, double eps)
 
std::vector< STK::SharedPointVector > calcPolyGridIntersection (const std::vector< STK::Vector3d > &poly, double xMin, double yMin, double xMax, double yMax, int rows, int cols, bool clip=false, bool closed=false)
 
istream & operator>> (istream &input, Tab1 &tab)
 
ostream & operator<< (ostream &output, Tab1 &tab)
 
std::istream & operator>> (std::istream &input, Tab2 &tab)
 
std::ostream & operator<< (std::ostream &output, Tab2 &tab)
 
istream & operator>> (istream &input, Tab3 &tab)
 
btVector3 toBtVector (const STK::Vector3< btScalar > &v)
 
STK::Vector3< btScalar > fromBtVector (const btVector3 &v)
 
btMatrix3x3 toBtMatrix (const Matrix4x4f &m)
 
void deleteCollisionShape (btCollisionShape *shape)
 
btTransform interpolateTransform (const btTransform &t0, const btTransform &t1, btScalar s)
 
bool checkGLError (const char *prefix=nullptr)
 
bool checkFBOStatus ()
 
void dumpGLState ()
 
bool isMipmapFilter (GLenum filter)
 
void convertToIndexedTriangles (const std::vector< unsigned int > &idx, GLenum mode, int group, std::vector< IndexTriangle > &idx_triangles)
 
std::shared_ptr< STK::PolylineRender2DclipPolylineRender2D (const STK::PolylineRender2D &pl, const std::vector< STK::Vector2f > &clip_poly, int precision=5)
 
bool sortByDepthAndBatch (const std::shared_ptr< RenderItem2D > &i1, const std::shared_ptr< RenderItem2D > &i2)
 
STK::Matrix4x4f createPickMatrix (const STK::Viewport &vp, float x, float y, float hitW, float hitH)
 Create a projection matrix for hit testing around the given (x,y) point in screen coordinates.
 
STK::Vector3f unproject (const STK::Vector3f &in, const STK::Matrix4x4f &modelView, const STK::Matrix4x4f &projection, const STK::Vector4f &viewport)
 
void buildSphere (float radius, int slices, int stacks, STK::VertexBuffer *vtx_buffer, std::vector< GLushort > &idx)
 
void buildCylinderSector (float radius, float height, float sector_angle, int slices, bool reverse, STK::VertexBuffer *vtx_buffer, std::vector< GLushort > &top_idx, std::vector< GLushort > &bot_idx, std::vector< GLushort > &mid_idx)
 
void buildCylinder (float radius, float height, int slices, bool reverse, STK::VertexBuffer *vtx_buffer, std::vector< GLushort > &top_idx, std::vector< GLushort > &bot_idx, std::vector< GLushort > &mid_idx)
 
std::vector< STK::Vector2fgenerateRoundedRectangle (const STK::Vector2f &bl, const STK::Vector2f &br, const STK::Vector2f &tr, const STK::Vector2f &tl, float corner_radius_x, float corner_radius_y, int num_corner_pts=10)
 

Variables

std::string bin_dir = ""
 Binary directory, where the .exe or entry .dll/.so file is placed.
 
std::string root_dir = ""
 Root installation directory. Data and binary directories should be subdirectories of this.
 
std::string app_data_dir = ""
 Installation wide data directory.
 
std::string user_data_dir = ""
 Per-user data directory.
 
bool is_initialized = false
 Check if application has been initialized.
 
ILoggerdefaultLog = nullptr
 
template<typename From , typename To >
constexpr bool safe_type_cast_v = safe_type_cast<From, To>::value
 
constexpr double rad_to_deg = 180.0/M_PI
 Conversion factor from radians to degrees.
 
constexpr float rad_to_deg_f = static_cast<float>(180.0f / M_PI)
 
constexpr double deg_to_rad = M_PI/180.0
 Conversion factor from degrees to radians.
 
constexpr float deg_to_rad_f = static_cast<float>(M_PI / 180.0f)
 
constexpr double pi = M_PI
 
constexpr double twopi = 2*M_PI
 
constexpr double halfpi = 0.5*M_PI
 
constexpr float pi_f = static_cast<float>(M_PI)
 
constexpr float twopi_f = 2.0f * pi_f
 
constexpr float halfpi_f = 0.5f * pi_f
 

Detailed Description

file M3DBoundingVolume.h

brief

file stkFileInfo.h

brief

file stkProgressHandler.h

brief

The angular filter wraps around at 2PI, is otherwise a normal first order lowpass filter. It's well suited to filter yaw angles, for example.

Simple digital first-order low-pass filter.

The filter clamps the maximum rate of change.

file stkUniformPoissonDiscSampler.h

brief

file M3DB3DMParser.h

brief

file stkMarkerObject.h

brief

file stkMeshUtils.h

brief

file stkScreen.h

brief

file stkStkVertexBuffer2D.h

brief

file stkVertexBufferManager.h

brief

Enumeration Type Documentation

◆ ResampMethod

enum class STK::ResampMethod
strong

ScaleImage - Image scaling algorithms. This image transform class is used to scale an image up or down by a an arbitrary factor in each direction. You can select from a range of different algorithms with various tradeoffs between image quality and execution speed.

Scaling Algorithms

We will now give a brief overview of the scaling algorithms, all the linear and higher-order filters (from Triangle and onwards) are applied in a similar manner in which the filter is first applied on the rows and then on the columns of the transformed rows. All these filters are symmetrical, i.e the $ f(x) = f(-x)$ for $x$ in the negative interval corresponding to the interval given in the formula.

Most of these filters are based on code by Dale Schumacher from the book Graphics Gems III.

Nearest value

This is the simplest (and fastest) algorithm, but unfortunately also the one that gives poorest results, especially for downscaling. It simply uses the nearest pixel value in the input image as pixel value in the output image.

Box Filter

This is also a simple an quite fast method, which also gives relatively good results, albeit with some blurring. The output pixel value is simply taken as an unweighted average of the input pixel values.

Triangle Filter

This method uses a linear interpolation of the input values

Bell Filter

This method uses quadratic interpolation of the input value.

\[
f(x) = \left\{\begin{array}{ll}
\frac{3}{4} - x^2 & \mbox{~if~} x \in [0. \frac{1}{2})\\
\frac{1}{2}\left( x - \frac{3}{2}\right)^2
     &\mbox{~if~} x \in [\frac{1}{2},\frac{3}{2})\\
0 &\mbox{~if~} x > \frac{3}{2}\\
\end{array}\right.
\]

B-spline filter

This filter uses a cubic B-spline function:

\[
f(x) = \left\{\begin{array}{ll}
\frac{1}{2} x^3  - x^2 + \frac{2}{3} & \mbox{~if~} x \in [0, 1)\\
\frac{1}{6}( 2 - x)^3
     &\mbox{~if~} x \in [1,2)\\
0 &\mbox{~if~} x > 2\\
\end{array}\right.
\]

Lanczos Filter

This method uses a trigonometric filter:

\[
f(x) = \left\{\begin{array}{ll}
3\frac{sin(\pi x)\sin\left(\frac{\pi x}{3}\right)}{\pi x}
  & \mbox{~if~} x \in [0, 3)\\
0 &\mbox{~if~} x > 3\\
\end{array}\right.
\]

Mitchell Filter

This filter is the most complex of them. Suffice it to say that it gives very good results, and take a lot of time. See source code for details.

Author
Thomas E. Sevaldrud
See also
STK::Image
STK::Color4i
Enumerator
NEAREST 

Nearest value.

BOX_NEAREST 

Nearest value for magnification, box filter for minification.

FILTER 

Unknown type filter (degree = 3).

LINEAR 

Linear filter.

QUADRATIC 

Quadratic filter.

CUBIC 

Cubic B-spline filter.

LANCZOS 

Trigonometric filter.

MITCHELL 

Mitchell filter.

MAX_COUNT 

Use color with most occurences.

Function Documentation

◆ buildCylinder()

void STK::buildCylinder ( float  radius,
float  height,
int  slices,
bool  reverse,
STK::VertexBuffer vtx_buffer,
std::vector< GLushort > &  top_idx,
std::vector< GLushort > &  bot_idx,
std::vector< GLushort > &  mid_idx 
)
inline

Build an indexed geometry cylinder. This method will build a cylinder with three index arrays, top and bottom which are GL_TRIANGLE_FAN, and middle which is GL_TRIANGLE_STRIP.

◆ buildCylinderSector()

void STK::buildCylinderSector ( float  radius,
float  height,
float  sector_angle,
int  slices,
bool  reverse,
STK::VertexBuffer vtx_buffer,
std::vector< GLushort > &  top_idx,
std::vector< GLushort > &  bot_idx,
std::vector< GLushort > &  mid_idx 
)

Build an indexed geometry cylinder sector. This method will build a cylinder with three index arrays, top and bottom which are GL_TRIANGLE_FAN, and middle which is GL_TRIANGLE_STRIP. The sector angle is how many degrees of the sector we should cover.

◆ buildSphere()

void STK::buildSphere ( float  radius,
int  slices,
int  stacks,
STK::VertexBuffer vtx_buffer,
std::vector< GLushort > &  idx 
)

Build an indexed geometry sphere mesh. This method builds a sphere mesh as one continous triangle strip.

◆ calcNormalVector()

void STK::calcNormalVector ( const STK::Image img,
int  x,
int  y,
double  dx,
double  dy,
double &  nx,
double &  ny,
double &  nz 
)

Calculate normal vector for image pixel This method will calculate the normal vector for an image at pixel (x, y). The pixel size is (dx, dy).

◆ centroid()

template<class T >
STK::Vector2< T > STK::centroid ( const std::vector< STK::Vector2< T > > &  pts)

Calculate centroid (average position) of the point list.

◆ checkGLError()

bool STK::checkGLError ( const char *  prefix = nullptr)
inline

GLUtils - Short description. Detailed description.

◆ closestDistanceBetweenLines()

template<class Type >
Type STK::closestDistanceBetweenLines ( const STK::Vector3< Type > &  L1P0,
const STK::Vector3< Type > &  L1Dir,
const STK::Vector3< Type > &  L2P0,
const STK::Vector3< Type > &  L2Dir,
STK::Vector3< Type > &  L1P,
STK::Vector3< Type > &  L2P 
)

Calculate closest points on two lines. This method will calculate the two points that are closest to each other on the two lines defined by L1P0 along L1Dir vector and L2P0 along L2Dir vector. The output points are L1P on the L1 line and L2P on the L2 line. The distance between these points (shortest distance between the lines) is returned in the return value.

Algorithm from http://geomalgorithms.com/a07-_distance.html

◆ convertToIndexedTriangles()

void STK::convertToIndexedTriangles ( const std::vector< unsigned int > &  idx,
GLenum  mode,
int  group,
std::vector< IndexTriangle > &  idx_triangles 
)

Convert the input index array to indexed triangles. The input data can be either GL_TRIANGLES, GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN The group parameter can be used to organize triangles according to some ID.

◆ createPickMatrix()

STK::Matrix4x4f STK::createPickMatrix ( const STK::Viewport vp,
float  x,
float  y,
float  hitW,
float  hitH 
)
inline

Create a projection matrix for hit testing around the given (x,y) point in screen coordinates.

SceneUtils - Utility functions related to scene graph and scene rendering

◆ distanceLinePoint()

template<class Type >
bool STK::distanceLinePoint ( const STK::Vector3< Type > &  p1,
const STK::Vector3< Type > &  p2,
const STK::Vector3< Type > &  p,
Type &  d 
)

Calculate shortest distance between the point p and the line segment from p1 to p2. The function returns true if the projected point falls between the end points of the segment, false otherwise.

◆ initApplication()

void STK::initApplication ( )

Initialize application This method parses the command line and sets any recognized options

◆ rayPlaneIntersection()

template<class Type >
bool STK::rayPlaneIntersection ( const STK::Vector3< Type > &  planePoint,
const STK::Vector3< Type > &  planeNormal,
const STK::Vector3< Type > &  linePoint,
const STK::Vector3< Type > &  lineDirection,
STK::Vector3< Type > &  intersection 
)
inline

Calculate intersection between a ray and a plane. The plane is defined by a point and a normal vector, the ray by a point and a direction vector. Both direction and normal vectors must be normalized.

◆ raySphereIntersection()

template<class Type >
bool STK::raySphereIntersection ( const STK::Vector3< Type > &  rayOrigin,
const STK::Vector3< Type > &  rayVector,
const STK::Vector3< Type > &  sphCenter,
Type  sphRadius,
Type &  t 
)
inline

Calculate intersection between a ray and a sphere, if any. Returns true if an intersection was found, false if not. The t parameter indicates where on the ray the intersection was found. The actual point can then be calculated as

intersectionPoint = rayOrigin + t*rayVector

Note that the ray is considered directional and you can only get intersections on one side of the origin point (along the direction vector).

◆ rayTriangleIntersection()

template<class Type >
bool STK::rayTriangleIntersection ( const STK::Vector3< Type > &  rayOrigin,
const STK::Vector3< Type > &  rayVector,
const STK::Vector3< Type > &  vertex0,
const STK::Vector3< Type > &  vertex1,
const STK::Vector3< Type > &  vertex2,
STK::Vector3< Type > &  outIntersectionPoint 
)
inline

Calculate intersection between a ray and a triangle, if any. Returns true if an intersection was found, false if not. The intersection point is returned in the outIntersectionPoint argument.

Note that the ray is considered infinite and you can get intersections on both sides of the origin point.

◆ segmentIntersection()

template<typename Type >
std::optional< STK::Vector2< Type > > STK::segmentIntersection ( const STK::Vector2< Type > &  S1Start,
const STK::Vector2< Type > &  S1End,
const STK::Vector2< Type > &  S2Start,
const STK::Vector2< Type > &  S2End 
)

Find the intersection point between two segments in 2d. Algorithm from: https://stackoverflow.com/a/565282.

In the case of collinear points, we return the point closest to the S1Start point.

Template Parameters
TypeThe precision level
Parameters
S1StartThe start point for the first segment
S1Endthe endpoint for the first segment
S2StartThe start point for the second segment
S2EndThe endpoint for the second segement
Returns
std::nullopt if no intersection, a point at which they intersect otherwise