cherish
|
Some generic methods compiled into one class. Methods that describe: More...
#include <Utilities.h>
Static Public Member Functions | |
static QColor | getQColor (const osg::Vec4f &color) |
static osg::Vec4f | getOsgColor (const QColor &color) |
static bool | areStrokesProjectable (const std::vector< entity::Stroke *> &strokes, entity::Canvas *source, entity::Canvas *target, osg::Camera *camera) |
static bool | getViewProjectionWorld (osgGA::GUIActionAdapter &aa, osg::Matrix &VPW, osg::Matrix &invVPW) |
static void | getFarNear (double x, double y, const osg::Matrix &invVPW, osg::Vec3f &near, osg::Vec3f &far) |
static bool | getRayPlaneIntersection (const osg::Plane &plane, const osg::Vec3f ¢er, const osg::Vec3f &nearPoint, const osg::Vec3f &farPoint, osg::Vec3f &P, bool isLine=false) |
static bool | getModel (entity::Canvas *canvas, osg::Matrix &M, osg::Matrix &invM) |
static bool | getLocalFromGlobal (const osg::Vec3f &P, const osg::Matrix &invM, osg::Vec3f &p) |
static bool | getGlobalFromLocal (const osg::Vec3f &p, const osg::Matrix &M, osg::Vec3f &P) |
static double | getAngleTwoVectors (const osg::Vec2f &p1, const osg::Vec2f &p2, const osg::Vec2f &p3, const osg::Vec2f &p4) |
static osg::Vec3f | rotate2DPointAround (const osg::Vec3f ¢er, float theta, const osg::Vec3f &original) |
static bool | getSkewLinesProjection (const osg::Vec3f ¢er, const osg::Vec3f &farPoint, const osg::Vec3f &nearPoint, const osg::Vec3f &normal, osg::Vec3f &X1) |
static double | getSkewLinesDistance (const osg::Vec3d &r1, const osg::Vec3d &r2, const osg::Vec3d &v1, const osg::Vec3d &v2) |
static bool | getLinesIntersection (const osg::Vec3f &La1, const osg::Vec3f &La2, const osg::Vec3f &Lb1, const osg::Vec3f &Lb2, osg::Vec3f &intersection) |
static int | getCanvasesIntersection (entity::Canvas *current, entity::Canvas *previous, osg::Vec3f &p1, osg::Vec3f &p2, osg::Vec3f &p3, osg::Vec3f &p4) |
static int | getPlanesIntersection (entity::Canvas *canvas1, entity::Canvas *canvas2, osg::Vec3f &iP, osg::Vec3f &u) |
static osg::Vec3f | projectPointOnLine (const osg::Vec3f &iP, const osg::Vec3f &u, const osg::Vec3f &P) |
static double | distanceTwoPoints (const osg::Vec3f &P1, const osg::Vec3f &P2) |
static osg::Vec3f | getAnchorLineSegment (const osg::Vec3f &P0, const osg::Vec3f &P1) |
static QCursor | getCursorFromMode (cher::MOUSE_MODE mode) |
static bool | getCameraPosition (entity::SVMData *svm, osg::Vec3f &eye, osg::Vec3f ¢er, osg::Vec3f &up) |
Some generic methods compiled into one class. Methods that describe:
|
static |
A tester method in order to check if a set of strokes can be projected into a selected canvas under the given view point.
strokes | is the set of selected strokes |
source | is the Canvas which contains the set of strokes to project |
target | is the Canvas on which the projection should be done |
camera | is the camera view true if all the strokes can be projected successfully. |
|
static |
A method to estimate Euclidean distance between two points in 3D.
P1 | is the first 3D point. |
P2 | is the second 3D point. |
|
static |
A method to obtain coordinate of the second point of entity::LineSegment which is anchored to canvas' local u and v coordinates.
canvas | is the canvas within which the segment is drawn. |
P0 | is the first point of segment, |
P1 | is the second point on segment, which is a subject to change to the result point. |
|
static |
A method which obtains an angle between two vectors in 2d. For more info, see: http://www.euclideanspace.com/maths/algebra/vectors/angleBetween/index.htm .
p1 | is the first point of the first vector. |
p2 | is the second point of the first vector. |
p3 | is the first point of the second vector. |
p4 | is the second point of the second vector. |
|
static |
A method to obtain camera pose given 4 intersecting rays (obtained from entity::SVMData). The algorithm is as follows: first, find 4 intersections between each neighboring rays (or use all possible pair?). Second, calculate the camera eye - average of the calculated four intersections. The camera's center vector passes through one of the wire's centers, and the up vector is always constant - (0,1,0).
|
static |
A method to obtain intersection between two canvases (planes) so that to do projection on the intersection onto the second canvas.
current | is the first canvas |
previous | is the second canvas (where the intersection will be cast on) |
p1 |
|
static |
UI method to obtain cursor data based on the given mouse mode.
|
static |
A method to obtain far and near points of the screen point that cast a projection ray.
x | - x-coordinate of the screen |
y | - y-coordinate of the screen |
invVPW | - inverse matrix of View-Projection-World matrix |
near | is the result 3D point on the near point on the cast ray |
far | is the result 3D point as the far point on the cast ray. |
|
static |
A method which is inverse to the method getLocalFromGlobal().
|
static |
A method to obtain an intersection between the two lines. Each line is presented by two points in 3D space. The algorithm treats the lines as skew and the intersection is calculated as average between two projections on each line. The projection between the skew lines is a shortest distance between the lines.
La1 | is the first 3D point on first line. |
La2 | is the second 3D point on first line. |
Lb1 | is the first 3D point on second line. |
Lb2 | is the second 3D point on second line. |
intersection | is the result intersection. |
|
static |
A method to convert a global point into local system of coordinates.
P | is the requested point to convert |
invM | is an inverted model matrix |
p | is the result 2D point (local system of coordinates). |
|
static |
A method to obtain model matrix (global to local conversion matrix) from a given canvas.
canvas | is the 2D plane canvas from which to derive the model matrix |
M | is the result model matrix |
invM | is the result inverse of model matrix |
|
static |
A method to convert a Qt color representation into an OSG.
|
static |
A method to obtaib intersection between two planes. For more details on the algorithm, see: http://geomalgorithms.com/a05-_intersect-1.html
|
static |
A method to convert an OSG color representation into a Qt
|
static |
A method to obtain intersection point between a given plane and a line (ray).
plane | is the given plane |
center | is an arbitrary point on the plane that represents the plane's center (global coordinates). |
nearPoint | is the 3D near point of the ray that was cast from a screen point |
farPoint | is the 3D far point of the ray that was cast from a screen point |
P | is the result point that represents intersection of the plane and a ray that is given by far and near points |
isLine | is boolean indicating whether we deal with ray (false) or line (true). Ray may not intersect the plane if both points lie above or below the plane. |
|
static |
A method to obtain a distance between skew rays. For more info, see: https://en.wikipedia.org/wiki/Skew_lines
|
static |
A method to obtain a distance between skew lines. For more info, see: http://www2.washjeff.edu/users/mwoltermann/Dorrie/69.pdf or here: http://paulbourke.net/geometry/pointlineplane/
center | is the first point P1 (see notations in the link above) |
farPoint | is to describe the line on which P1 lies |
nearPoint | is the second point P2 |
normal | is to describe the line on which P2 lies |
X1 | is the projection point on first line onto second line |
|
static |
A method to obtain two matrices - VPW and its invertse given the action adapter.
aa | is OSG-based variable from which camera, view and other matrices can be derived. |
VPW | is the output View-Projection-World matrix |
invVPW | is the ourput inverse of View-Projection-World matrix. |
|
static |
A method to project 3d point onto 3D line.
iP | is the global point on the line. |
u | is the vector defining the line direction. |
P | is the point to project. |
|
static |
A method to rotate a 2D point around another point on a specified angle. The input and output points have "local point" format: [u,v,0].
center | is the point around which the rotation will be done. |
theta | is the angle of rotation in radians. |
original | is the point to rotate. |