--- title: "Getting Started With R and Docker" author: Timothy Deitz, Clinical Psychologist & Data Science Consultant date: '2019-12-11' categories: - Docker tags: - Docker output: blogdown::html_page: toc: no ---
In this post I demonstrate how to deploy a Shiny app to your local browser using Docker. By stepping through this process, I pave the way for more complex deployments and hosting solutions.
To begin, create a project folder on my local drive
mkdir rocker_proj
Then retrieve the rocker\shiny-verse
image from Dockerhub.
docker pull rocker\shiny-verse
Check that the image is showing up locally
docker image ls
## REPOSITORY TAG IMAGE ID CREATED SIZE
## rocker/shiny-verse latest 94490fbd4d3b 6 days ago 1.86GB
## mysql latest d435eee2caa5 2 weeks ago 456MB
## nginx latest 231d40e811cd 2 weeks ago 126MB
## bretfisher/jekyll-serve latest 144799b59c39 5 months ago 269MB
## openanalytics/shinyproxy-demo latest 9a83d7d80ebf 10 months ago 925MB
## postgres 9.6.2 b3b8a2229953 2 years ago 267MB
## postgres 9.6.1 4023a747a01a 2 years ago 265MB
Yes!
Now spin up a container using the image I just downloaded:
docker container run --rm -p 3838:3838 -v /Users/timothyjamesdeitz/rocker_proj/srv/shinyapps/:/srv/shiny-server/ -v /Users/timothyjamesdeitz/rocker_proj/srv/shinylog/:/var/log/shiny-server/ rocker/shiny-verse
The -v flag refers to a volume. Volumes let the container access local files on the host. Here I specify two volumes, which share an overarching directory srv
. One of the volumes will contain the app itself, /Users/timothyjamesdeitz/rocker_proj/srv/shinyapps/
, and the other will contain the app logs /Users/timothyjamesdeitz/rocker_proj/srv/shinylog/:/var/log/shiny-server/
. As specified on the Dockerhub page, the container should run on port 3838, so I indicate this above. I also ensure that the container will be destroyed as soon as we take it down, using the --rm
flag. The last part of the call rocker/shiny-verse
refers to the name of the image itself. It is important to note that the shell prompt will be unavailable while the container is running. To solve this, I could have run the container in the background, using the -d
flag.
Next, I create a new R Studio Project (a shiny app) inside the /shinyapps/
subfolder.
Finally, I head to the browser and check that the app is appearing:
That’s all there is to it!
Also notice that because I created a volume, I can edit the app code itself and changes will immediately show up in the browser. For example, you can see that I’ve boldened and italicised the slider label (it wasn’t like that originally).


Pose and Resectioning¶
Theia contains efficient and robust implementations of the following pose and resectioning algorithms. We attempted to make each method as general as possible so that users were not tied to Theia data structures to use the methods. The interface for all pose methods uses Eigen types for feature positions, 3D positions, and pose rotations and translations.
Perspective Three Point (P3P)¶
- bool PoseFromThreePoints(const Eigen::Vector2d feature_position[3], const Eigen::Vector3d world_point[3], std::vector<Eigen::Matrix3d>* solution_rotations, std::vector<Eigen::Vector3d>* solution_translations)¶
Computes camera pose using the three point algorithm and returns all possible solutions (up to 4). Follows steps from the paper “A Novel Parameterization of the Perspective-Three-Point Problem for a direct computation of Absolute Camera position and Orientation” by [Kneip]. This algorithm has been proven to be up to an order of magnitude faster than other methods. The output rotation and translation define world-to-camera transformation.
feature_position: Image points corresponding to model points. These should be calibrated image points as opposed to pixel values.
world_point: 3D location of features.
solution_rotations: the rotation matrix of the candidate solutions
solution_translation: the translation of the candidate solutions
returns: Whether the pose was computed successfully, along with the output parameters rotation and translation filled with the valid poses.
Five Point Relative Pose¶
- bool FivePointRelativePose(const Eigen::Vector2d image1_points[5], const Eigen::Vector2d image2_points[5], std::vector<Eigen::Matrix3d>* rotation, std::vector<Eigen::Vector3d>* translation)¶
Computes the relative pose between two cameras using 5 corresponding points. Algorithm is implemented based on “Recent Developments on Direct Relative Orientation” by [Stewenius5pt]. This algorithm is known to be more numerically stable while only slightly slower than the [Nister] method. The rotation and translation returned are defined such that \(E=[t]_{\times} * R\) and \(y^\top * E * x = 0\) where \(y\) are points from image2 and \(x\) are points from image1.
image1_points: Location of features on the image plane of image 1.
image2_points: Location of features on the image plane of image 2.
returns: Output the number of poses computed as well as the relative rotation and translation.
Four Point Algorithm for Homography¶
- bool FourPointHomography(const std::vector<Eigen::Vector2d>& image_1_points, const std::vector<Eigen::Vector2d>& image_2_points, Eigen::Matrix3d* homography)¶
Computes the 2D homography mapping points in image 1 to image 2 such that: \(x' = Hx\) where \(x\) is a point in image 1 and \(x'\) is a point in image 2. The algorithm implemented is the DLT algorithm based on algorithm 4.2 in [HartleyZisserman].
image_1_points: Image points from image 1. At least 4 points must be passed in.
image_2_points: Image points from image 2. At least 4 points must be passed in.
homography: The computed 3x3 homography matrix.
Eight Point Algorithm for Fundamental Matrix¶
- bool EightPointFundamentalMatrix(const std::vector<Eigen::Vector2d>& image_1_points, const std::vector<Eigen::Vector2d>& image_2_points, Eigen::Matrix3d* fundamental_matrix)¶
Computes the fundamental matrix relating image points between two images such that \(x' F x = 0\) for all correspondences \(x\) and \(x'\) in images 1 and 2 respectively. The normalized eight point algorithm is a speedy estimation of the fundamental matrix (Alg 11.1 in [HartleyZisserman]) that minimizes an algebraic error.
image_1_points: Image points from image 1. At least 8 points must be passed in.
image_2_points: Image points from image 2. At least 8 points must be passed in.
fundamental_matrix: The computed fundamental matrix.
returns: true on success, false on failure.
Perspective N-Point¶
- void DlsPnp(const std::vector<Eigen::Vector2d>& feature_position, const std::vector<Eigen::Vector3d>& world_point, std::vector<Eigen::Quaterniond>* solution_rotation, std::vector<Eigen::Vector3d>* solution_translation)¶
Computes the camera pose using the Perspective N-point method from “A Direct Least-Squares (DLS) Method for PnP” by [Hesch] and Stergios Roumeliotis. This method is extremely scalable and highly accurate for the PnP problem. A minimum of 4 points are required, but there is no maximum number of points allowed as this is a least-squared approach. Theoretically, up to 27 solutions may be returned, but in practice only 4 real solutions arise and in almost all cases where n >= 6 there is only one solution which places the observed points in front of the camera. The returned rotation and translations are world-to-camera transformations.
feature_position: Normalized image rays corresponding to model points. Must contain at least 4 points.
points_3d: 3D location of features. Must correspond to the image_ray of the same index. Must contain the same number of points as image_ray, and at least 4.
solution_rotation: the rotation quaternion of the candidate solutions
solution_translation: the translation of the candidate solutions
Four Point Focal Length¶
- int FourPointPoseAndFocalLength(const std::vector<Eigen::Vector2d>& feature_positions, const std::vector<Eigen::Vector3d>& world_points, std::vector<Eigen::Matrix<double, 3, 4>>* projection_matrices)¶
Computes the camera pose and unknown focal length of an image given four 2D-3D correspondences, following the method of [Bujnak]. This method involves computing a grobner basis from a modified constraint of the focal length and pose projection.
feature_position: Normalized image rays corresponding to model points. Must contain at least 4 points.
points_3d: 3D location of features. Must correspond to the image_ray of the same index. Must contain the same number of points as image_ray, and at least 4.
projection_matrices: The solution world-to-camera projection matrices, inclusive of the unknown focal length. For a focal length f and a camera calibration matrix \(K=diag(f, f, 1)\), the projection matrices returned are of the form \(P = K * [R | t]\).
Five Point Focal Length and Radial Distortion¶
- bool FivePointFocalLengthRadialDistortion(const std::vector<Eigen::Vector2d>& feature_positions, const std::vector<Eigen::Vector3d>& world_points, const int num_radial_distortion_params, std::vector<Eigen::Matrix<double, 3, 4>>* projection_matrices, std::vector<std::vector<double>>* radial_distortions)¶
Compute the absolute pose, focal length, and radial distortion of a camera using five 3D-to-2D correspondences [Kukelova]. The method solves for the projection matrix (up to scale) by using a cross product constraint on the standard projection equation. This allows for simple solution to the first two rows of the projection matrix, and the third row (which contains the focal length and distortion parameters) can then be solved with SVD on the remaining constraint equations from the first row of the projection matrix. See the paper for more details.
feature_positions: the 2D location of image features. Exactly five features must be passed in.
world_points: 3D world points corresponding to the features observed. Exactly five points must be passed in.
- num_radial_distortion_params: The number of radial distortion paramters to
- solve for. Must be 1, 2, or 3.
- projection_matrices: Camera projection matrices (that encapsulate focal
- length). These solutions are only valid up to scale.
radial_distortions: Each entry of this vector contains a vector with the radial distortion parameters (up to 3, but however many were specified in num_radial_distortion_params).
return: true if successful, false if not.
Three Point Relative Pose with a Partially Known Rotation¶
- void ThreePointRelativePosePartialRotation(const Eigen::Vector3d& rotation_axis, const Eigen::Vector3d image_1_rays[3], const Eigen::Vector3d image_2_rays[3], std::vector<Eigen::Quaterniond>* soln_rotations, std::vector<Eigen::Vector3d>* soln_translations)¶
Computes the relative pose between two cameras using 3 correspondences and a known vertical direction as a Quadratic Eigenvalue Problem [SweeneyQEP]. Up to 6 solutions are returned such that \(image_2_rays = R * image_1_rays + t\). The axis that is passed in as a known axis of rotation (when considering rotations as an angle axis). This is equivalent to aligning the two cameras to a common direction such as the vertical direction, which can be done using IMU data.
Four Point Relative Pose with a Partially Known Rotation¶
- void FourPointRelativePosePartialRotation(const Eigen::Vector3d& rotation_axis, const Eigen::Vector3d image_1_origins[4], const Eigen::Vector3d image_1_rays[4], const Eigen::Vector3d image_2_origins[4], const Eigen::Vector3d image_2_rays[4], std::vector<Eigen::Quaterniond>* soln_rotations, std::vector<Eigen::Vector3d>* soln_translations)¶
Computes the relative pose between two generalized cameras using 4 correspondences and a known vertical direction as a Quadratic Eigenvalue Problem [SweeneyQEP]. A generalized camera is a camera setup with multiple cameras such that the cameras do not have the same center of projection (e.g., a multi-camera rig mounted on a car). Up to 8 solutions are returned such that \(image_2_rays = R * image_1_rays + t\). The axis that is passed in as a known axis of rotation (when considering rotations as an angle axis). This is equivalent to aligning the two cameras to a common direction such as the vertical direction, which can be done using IMU data.


What is the Watson mission statement?
To enhance health and nutrition worldwide.
What is the Watson vision statement?
Watson is an Invested Fellowship Fostering Health and Happiness for All
What are the Watson Tag Lines
Food/Beverage
We make foods healthier
Bakery
Better ingredients for better baking
Supplement
We make the ingredients for a healthy tomorrow
Who are the companies strategic customers?
What is the Strategic Customer Guidelines:
- Strategic Customers are always priority #1.
- Look after the company's financial interest and remember Strategic Customers are a vital asset.
- Use the process. If the process does not meet Strategic Customer needs, consider woprking outside the process to satisfy the customer's request. (Does not apply to GMP Processes.)
- Keep others int he company informed.
What year was Watson founded?
Watson was founded in 1939


{% include meta.html %}
Design Neverland
Adventures in Design + Development
{% include masthead.html %}
{{ content }}
{% include analytics.html %}


Introduction
Using the queries of Protocol 1 on Google, among the proposed results there were always a special section, at the top of the page, where academic results were shown. Since that, we wondered if the debate was also discussed in this area and therefore it was recognized as real. We went to investigate among the academic circles, using as primary sources of aggregators of information two search engines recognized by the scientific community: Google Scholar and Scopus.
Besides the use of the queries of protocol 1, we decided to use even the papers which cited the text which named the dispute “Filter Bubble” in 2011 with the publication of "The Filter Bubble: What The Internet Is Hiding From You”.
To analyze completely the discussion, it was decided to categorize documents according to some aspects like title, authors, year, location continent, article typology (proposal or research), university fonts, cited by and topic.
Then were made four graphs:
- the first one shows how the topic increased in a significant way since 2011 and how academic started to talk in context of society and technology, and how the red dots (against the web personalization), in recent years are becoming increasingly present
- the second one shows different types of analysis of the dispute, divided by pro, con and neutral positions, by continent and by typology: research, proposal, case study, book, research with proposal, research with case study and at least research with case study and proposal. In this there’s an appendix in which we wanted to highlight the position of case studies.
- the third shows the analysis between the thematic areas of technology, society, privacy, information and others (psychology, philosophy, politics, marketing) and the quantity of pro, con and neutral position in every area.
- the last one shows the different position about the Web Personalization of the papers we analyzed. We decided to try to map them by starting from the one with a much more defined position in the debate. The highlighted dots define the papers with most explicit position about our research question, while all the grey dots are all the rest of the papers, connected in relation of how many times they cite themselves. It is possible to see where all these papers are positioned in the debate, like for example we see that there are much more papers in the middle-moderate area.


Q3BoundingBox_Copy |
( TQ3BoundingBox * _Nonnull ) Q3BoundingBox_Copy ( const TQ3BoundingBox * _Nonnull bBox, TQ3BoundingBox * _Nonnull result );
Copy a bounding box.
Available in inline form as Q3BFastoundingBox_Copy.
- bBox
- Address of source bounding box.
- result
- Address of bounding box to set (may be the same as bBox).
Q3BoundingBox_Reset |
( TQ3BoundingBox * _Nonnull ) Q3BoundingBox_Reset ( TQ3BoundingBox * _Nonnull bBox );
Reset (set to empty) a bounding box.
Available in inline form as Q3FastBoundingBox_Reset.
- bBox
- Address of bounding box to reset.
Q3BoundingBox_Set |
( TQ3BoundingBox * _Nonnull ) Q3BoundingBox_Set ( TQ3BoundingBox * _Nonnull bBox, const TQ3Point3D * _Nonnull min, const TQ3Point3D * _Nonnull max, TQ3Boolean isEmpty );
Set a bounding box.
Available in inline form as Q3FastBoundingBox_Set.
- bBox
- Address of bounding box to set.
- min
- Address of point indicating minimum X, Y, and Z.
- max
- Address of point indicating maximum X, Y, and Z.
- isEmpty
- True if the bounding box is empty, false otherwise.
Q3BoundingBox_SetFromPoints3D |
( TQ3BoundingBox * _Nonnull ) Q3BoundingBox_SetFromPoints3D ( TQ3BoundingBox * _Nonnull bBox, const TQ3Point3D * _Nullable points3D, TQ3Uns32 numPoints, TQ3Uns32 structSize );
Set a bounding box to just enclose a set of 3D points.
- bBox
- Address of bounding box to set.
- points3D
- Array of 3D points. Should not be NULL unless numPoints == 0.
- numPoints
- How many points are in the array.
- structSize
- Size of each array element, typically sizeof(TQ3Point3D).
Q3BoundingBox_SetFromRationalPoints4D |
( TQ3BoundingBox * _Nonnull ) Q3BoundingBox_SetFromRationalPoints4D ( TQ3BoundingBox * _Nonnull bBox, const TQ3RationalPoint4D * _Nonnull rationalPoints4D, TQ3Uns32 numPoints, TQ3Uns32 structSize );
Set a bounding box to just enclose a set of 4D rational points.
- bBox
- Address of bounding box to set.
- rationalPoints4D
- Array of 4D rational points.
- numPoints
- How many points are in the array.
- structSize
- Size of each array element, typically sizeof(TQ3RationalPoint4D).
Q3BoundingBox_Union |
( TQ3BoundingBox * _Nonnull ) Q3BoundingBox_Union ( const TQ3BoundingBox * _Nonnull b1, const TQ3BoundingBox * _Nonnull b2, TQ3BoundingBox * _Nonnull result );
Compute the minimum bounding box that encloses both 'b1' and 'b2'.
- b1
- Address of one bounding box.
- b2
- Address of another bounding box.
- result
- Address of bounding box to set (may be the same as b1 and/or b2).
Q3BoundingBox_UnionPoint3D |
( TQ3BoundingBox * _Nonnull ) Q3BoundingBox_UnionPoint3D ( const TQ3BoundingBox * _Nonnull bBox, const TQ3Point3D * _Nonnull point3D, TQ3BoundingBox * _Nonnull result );
Return the minimum bounding box that encloses both 'bBox' and 'point3D'.
- bBox
- Address of initial bounding box.
- point3D
- Address of a point to enclose.
- result
- Address of bounding box to set (may be the same as bBox).
Q3BoundingBox_UnionRationalPoint4D |
( TQ3BoundingBox * _Nonnull ) Q3BoundingBox_UnionRationalPoint4D ( const TQ3BoundingBox * _Nonnull bBox, const TQ3RationalPoint4D * _Nonnull rationalPoint4D, TQ3BoundingBox * _Nonnull result );
Return the minimum bounding box that encloses both 'bBox' and 'rationalPoint4D'.
- bBox
- Address of initial bounding box.
- rationalPoint4D
- Address of a point to enclose.
- result
- Address of bounding box to set (may be the same as bBox).
Q3BoundingSphere_Copy |
( TQ3BoundingSphere * _Nonnull ) Q3BoundingSphere_Copy ( const TQ3BoundingSphere * _Nonnull bSphere, TQ3BoundingSphere * _Nonnull result );
Copy a bounding sphere.
Available in inline form as Q3FastBoundingSphere_Copy.
- bSphere
- Address of source bounding sphere.
- result
- Address of bounding sphere to set (may be the same as bSphere).
Q3BoundingSphere_Reset |
( TQ3BoundingSphere * _Nonnull ) Q3BoundingSphere_Reset ( TQ3BoundingSphere * _Nonnull bSphere );
Reset (set to empty) a bounding sphere.
Available in inline form as Q3FastBoundingSphere_Reset.
- bSphere
- Address of bounding sphere to reset.
Q3BoundingSphere_Set |
( TQ3BoundingSphere * _Nonnull ) Q3BoundingSphere_Set ( TQ3BoundingSphere * _Nonnull bSphere, const TQ3Point3D * _Nonnull origin, float radius, TQ3Boolean isEmpty );
Set a bounding sphere.
Available in inline form as Q3FastBoundingSphere_Set.
- bSphere
- Address of bounding sphere to set.
- origin
- Address of point indicating sphere origin.
- radius
- Sphere radius.
- isEmpty
- True if the bounding sphere is empty, false otherwise.
Q3BoundingSphere_SetFromPoints3D |
( TQ3BoundingSphere * _Nonnull ) Q3BoundingSphere_SetFromPoints3D ( TQ3BoundingSphere * _Nonnull bSphere, const TQ3Point3D * _Nonnull points3D, TQ3Uns32 numPoints, TQ3Uns32 structSize );
Set a bounding sphere to just enclose a set of 3D points.
- bSphere
- The bounding sphere to update.
- points3D
- Array of 3D points.
- numPoints
- How many points are in the array.
- structSize
- Size of each array element, typically sizeof(TQ3Point3D).
Q3BoundingSphere_SetFromRationalPoints4D |
( TQ3BoundingSphere * _Nonnull ) Q3BoundingSphere_SetFromRationalPoints4D ( TQ3BoundingSphere * _Nonnull bSphere, const TQ3RationalPoint4D * _Nonnull rationalPoints4D, TQ3Uns32 numPoints, TQ3Uns32 structSize );
Set a bounding sphere to just enclose a set of 4D rational points.
- bSphere
- Address of bounding sphere to set.
- rationalPoints4D
- Array of 4D rational points.
- numPoints
- How many points are in the array.
- structSize
- Size of each array element, typically sizeof(TQ3RationalPoint4D).
Q3BoundingSphere_Union |
( TQ3BoundingSphere * _Nonnull ) Q3BoundingSphere_Union ( const TQ3BoundingSphere * _Nonnull s1, const TQ3BoundingSphere * _Nonnull s2, TQ3BoundingSphere * _Nonnull result );
Compute the minimum bounding sphere that encloses both 's1' and 's2'.
- s1
- Address of one bounding sphere.
- s2
- Address of another bounding sphere.
- result
- Address of bounding sphere to set (may be the same as s1 and/or s2).
Q3BoundingSphere_UnionPoint3D |
( TQ3BoundingSphere * _Nonnull ) Q3BoundingSphere_UnionPoint3D ( const TQ3BoundingSphere * _Nonnull bSphere, const TQ3Point3D * _Nonnull point3D, TQ3BoundingSphere * _Nonnull result );
Return the minimum bounding sphere that encloses both 'bSphere' and 'point3D'.
- bSphere
- Address of initial bounding sphere.
- point3D
- Address of a point to enclose.
- result
- Address of bounding sphere to set (may be the same as bSphere).
Q3BoundingSphere_UnionRationalPoint4D |
( TQ3BoundingSphere * _Nonnull ) Q3BoundingSphere_UnionRationalPoint4D ( const TQ3BoundingSphere * _Nonnull bSphere, const TQ3RationalPoint4D * _Nonnull rationalPoint4D, TQ3BoundingSphere * _Nonnull result );
Return the minimum bounding sphere that encloses both 'bSphere' and 'rationalPoint4D'.
- bSphere
- Address of initial bounding sphere.
- rationalPoint4D
- Address of a point to enclose.
- result
- Address of bounding sphere to set (may be the same as bSphere).
Q3Math_InvSquareRoot |
( float ) Q3Math_InvSquareRoot ( float x );
Obtain a fast, but possibly inaccurate, inverse square root.
The available precision depends on the current architecture, but will
suffice for most non-accumulating 3D operations. If a reliable degree
of precision is required, 1.0/sqrt() should be used instead.
- x
- The number whose inverse square root should be returned.
Q3Math_SquareRoot |
( float ) Q3Math_SquareRoot ( float x );
Obtain a fast, but possibly inaccurate, square root.
The available precision depends on the current architecture, but will
suffice for most non-accumulating 3D operations. If a reliable degree
of precision is required, sqrt() should be used instead.
- x
- The number whose square root should be returned.
Q3Matrix3x3_Adjoint |
( TQ3Matrix3x3 * _Nonnull ) Q3Matrix3x3_Adjoint ( const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3Matrix3x3 * _Nonnull result );
Calculate adjoint of 3x3 matrix.
The adjoint of a matrix is a scalar multiple of the inverse of
the matrix. For some applications, the adjoint can be used in
place of the inverse. In particular:
adjoint(A) = determinant(A) * inverse(A)
- matrix3x3
- Address of a matrix to calculate the adjoint of.
- result
- Address of matrix to set (may be the same as matrix3x3).
Q3Matrix3x3_Copy |
( TQ3Matrix3x3 * _Nonnull ) Q3Matrix3x3_Copy ( const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3Matrix3x3 * _Nonnull result );
Copy a 3x3 matrix.
- matrix3x3
- Address of source matrix.
- result
- Address of destination matrix (may be the same as matrix3x3).
Q3Matrix3x3_Determinant |
( float ) Q3Matrix3x3_Determinant ( const TQ3Matrix3x3 * _Nonnull matrix3x3 );
Return the determinant of 3x3 matrix.
- matrix3x3
- Address of a matrix.
Q3Matrix3x3_Invert |
( TQ3Matrix3x3 * _Nonnull ) Q3Matrix3x3_Invert ( const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3Matrix3x3 * _Nonnull result );
Calculate the inverse of a 3x3 non-singular matrix.
- matrix3x3
- Address of non-singular matrix to invert.
- result
- Address of matrix to set (may be the same as matrix3x3).
Q3Matrix3x3_Multiply |
( TQ3Matrix3x3 * _Nonnull ) Q3Matrix3x3_Multiply ( const TQ3Matrix3x3 * _Nonnull m1, const TQ3Matrix3x3 * _Nonnull m2, TQ3Matrix3x3 * _Nonnull result );
Multiply two 3x3 matrices.
- m1
- Address of first matrix.
- m2
- Address of second matrix.
- result
- Address of matrix to set with m1*m2 (may be the same as m1 and/or m2).
Q3Matrix3x3_SetIdentity |
( TQ3Matrix3x3 * _Nonnull ) Q3Matrix3x3_SetIdentity ( TQ3Matrix3x3 * _Nonnull matrix3x3 );
Set a 3x3 matrix to the identity matrix.
- matrix3x3
- Address of matrix to set.
Q3Matrix3x3_SetRotate |
( TQ3Matrix3x3 * _Nonnull ) Q3Matrix3x3_SetRotate ( TQ3Matrix3x3 * _Nonnull matrix3x3, float angle );
Set a 3x3 matrix to rotate about the origin.
- matrix3x3
- Address of matrix to set.
- angle
- Angle to rotate (in radians).
Q3Matrix3x3_SetRotateAboutPoint |
( TQ3Matrix3x3 * _Nonnull ) Q3Matrix3x3_SetRotateAboutPoint ( TQ3Matrix3x3 * _Nonnull matrix3x3, const TQ3Point2D * _Nonnull origin, float angle );
Set a 3x3 matrix to rotate about a point.
This is equivalent to translating the point to the origin,
doing a rotation about the origin, and translating back.
- matrix3x3
- Address of matrix to set.
- origin
- Address of a 2D point about which to rotate.
- angle
- Angle to rotate (in radians).
Q3Matrix3x3_SetScale |
( TQ3Matrix3x3 * _Nonnull ) Q3Matrix3x3_SetScale ( TQ3Matrix3x3 * _Nonnull matrix3x3, float xScale, float yScale );
Set 3x3 matrix to scale in x, y.
- matrix3x3
- Address of matrix to set.
- xScale
- Amount to scale in x.
- yScale
- Amount to scale in y.
Q3Matrix3x3_SetTranslate |
( TQ3Matrix3x3 * _Nonnull ) Q3Matrix3x3_SetTranslate ( TQ3Matrix3x3 * _Nonnull matrix3x3, float xTrans, float yTrans );
Set a 3x3 matrix to translate in x, y.
- matrix3x3
- Address of matrix to set.
- xTrans
- Amount to translate in x.
- yTrans
- Amount to translate in y.
Q3Matrix3x3_Transpose |
( TQ3Matrix3x3 * _Nonnull ) Q3Matrix3x3_Transpose ( const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3Matrix3x3 * _Nonnull result );
Transpose a 3x3 matrix.
- matrix3x3
- Address of a matrix to transpose.
- result
- Address of matrix to set (may be the same as matrix3x3).
Q3Matrix4x4_Copy |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_Copy ( const TQ3Matrix4x4 * _Nonnull matrix4x4, TQ3Matrix4x4 * _Nonnull result );
Copy a 4x4 matrix.
- matrix4x4
- Address of source matrix.
- result
- Address of destination matrix (may be the same as matrix4x4).
Q3Matrix4x4_Determinant |
( float ) Q3Matrix4x4_Determinant ( const TQ3Matrix4x4 * _Nonnull matrix4x4 );
Return the determinant of 4x4 matrix.
- matrix4x4
- Address of a matrix.
Q3Matrix4x4_Invert |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_Invert ( const TQ3Matrix4x4 * _Nonnull matrix4x4, TQ3Matrix4x4 * _Nonnull result );
Calculate the inverse of a 4x4 non-singular matrix.
- matrix4x4
- Address of non-singular matrix to invert.
- result
- Address of matrix to set (may be the same as matrix4x4).
Q3Matrix4x4_Multiply |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_Multiply ( const TQ3Matrix4x4 * _Nonnull m1, const TQ3Matrix4x4 * _Nonnull m2, TQ3Matrix4x4 * _Nonnull result );
Multiply two 4x4 matrices.
- m1
- Address of first matrix.
- m2
- Address of second matrix.
- result
- Address of matrix to set with m1*m2 (may be the same as m1 and/or m2).
Q3Matrix4x4_SetIdentity |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetIdentity ( TQ3Matrix4x4 * _Nonnull matrix4x4 );
Set a 4x4 matrix to the identity matrix.
- matrix4x4
- Address of matrix to set.
Q3Matrix4x4_SetQuaternion |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetQuaternion ( TQ3Matrix4x4 * _Nonnull matrix4x4, const TQ3Quaternion * _Nonnull quaternion );
Set a 4x4 matrix from to the rotation represented by a quaternion.
- matrix4x4
- Address of matrix to set.
- quaternion
- Address of the quaternion to imitate.
Q3Matrix4x4_SetRotateAboutAxis |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetRotateAboutAxis ( TQ3Matrix4x4 * _Nonnull matrix4x4, const TQ3Point3D * _Nonnull origin, const TQ3Vector3D * _Nonnull axis, float angle );
Set 4x4 matrix to rotate about an arbitrary origin and axis.
Note that for correct results, the axis should be normalized
(i.e. have length = 1).
- matrix4x4
- Address of matrix to set.
- origin
- Address of a 2D point about which to rotate.
- axis
- Address of a 3D vector to use as the rotation axis.
- angle
- Angle to rotate (in radians).
Q3Matrix4x4_SetRotateAboutPoint |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetRotateAboutPoint ( TQ3Matrix4x4 * _Nonnull matrix4x4, const TQ3Point3D * _Nonnull origin, float xAngle, float yAngle, float zAngle );
Set a 4x4 matrix to rotate about axes through a point and
parallel to the X, Y, and Z axes (in that order).
This order of rotations is rarely useful, but it's kept for backwards
compatibility with QD3D.
- matrix4x4
- Address of matrix to set.
- origin
- Address of a 3D point about which to rotate.
- xAngle
- Angle to rotate about the translated X axis (in radians).
- yAngle
- Angle to rotate about the translated Y axis (in radians).
- zAngle
- Angle to rotate about the translated Z axis (in radians).
Q3Matrix4x4_SetRotateVectorToVector |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetRotateVectorToVector ( TQ3Matrix4x4 * _Nonnull matrix4x4, const TQ3Vector3D * _Nonnull v1, const TQ3Vector3D * _Nonnull v2 );
Set a 4x4 matrix to rotate vector 'v1' to 'v2'.
Note that for correct results, both vectors should be normalized
(i.e. have length = 1).
- matrix4x4
- Address of matrix to set.
- v1
- Address of "starting" vector.
- v2
- Address of "ending" vector.
Q3Matrix4x4_SetRotate_X |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetRotate_X ( TQ3Matrix4x4 * _Nonnull matrix4x4, float angle );
Set a 4x4 matrix to rotate about the X axis.
- matrix4x4
- Address of matrix to set.
- angle
- Angle to rotate (in radians).
Q3Matrix4x4_SetRotate_XYZ |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetRotate_XYZ ( TQ3Matrix4x4 * _Nonnull matrix4x4, float xAngle, float yAngle, float zAngle );
Set a 4x4 matrix to rotate about the X, Y, Z axes (in that order).
This order of rotations is rarely useful, but it's kept for backwards
compatibility with QD3D.
- matrix4x4
- Address of matrix to set.
- xAngle
- Angle to rotate about the X axis (in radians).
- yAngle
- Angle to rotate about the Y axis (in radians).
- zAngle
- Angle to rotate about the Z axis (in radians).
Q3Matrix4x4_SetRotate_Y |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetRotate_Y ( TQ3Matrix4x4 * _Nonnull matrix4x4, float angle );
Set a 4x4 matrix to rotate about the Y axis.
- matrix4x4
- Address of matrix to set.
- angle
- Angle to rotate (in radians).
Q3Matrix4x4_SetRotate_Z |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetRotate_Z ( TQ3Matrix4x4 * _Nonnull matrix4x4, float angle );
Set a 4x4 matrix to rotate about the Z axis.
- matrix4x4
- Address of matrix to set.
- angle
- Angle to rotate (in radians).
Q3Matrix4x4_SetScale |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetScale ( TQ3Matrix4x4 * _Nonnull matrix4x4, float xScale, float yScale, float zScale );
Set a 4x4 matrix to scale in x, y, z.
- matrix4x4
- Address of matrix to set.
- xScale
- Amount to scale in x.
- yScale
- Amount to scale in y.
- zScale
- Amount to scale in z.
Q3Matrix4x4_SetTranslate |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_SetTranslate ( TQ3Matrix4x4 * _Nonnull matrix4x4, float xTrans, float yTrans, float zTrans );
Set a 4x4 matrix to translate in x, y, z.
- matrix4x4
- Address of matrix to set.
- xTrans
- Amount to translate in x.
- yTrans
- Amount to translate in y.
- zTrans
- Amount to translate in z.
Q3Matrix4x4_Transpose |
( TQ3Matrix4x4 * _Nonnull ) Q3Matrix4x4_Transpose ( const TQ3Matrix4x4 * _Nonnull matrix4x4, TQ3Matrix4x4 * _Nonnull result );
Transpose a 4x4 matrix.
- matrix4x4
- Address of a matrix to transpose.
- result
- Address of matrix to set (may be the same as matrix4x4).
Q3Param2D_AffineComb |
( TQ3Param2D * _Nonnull ) Q3Param2D_AffineComb ( const TQ3Param2D * _Nonnull params2D, const float * _Nonnull weights, TQ3Uns32 numPoints, TQ3Param2D * _Nonnull result );
Return weighted combination of several 2D parameter points.
Provide an array of points and a parallel array of weights, and
this function will compute the weighted combination.
Although the mathematical definition of an affine combination requires
that the weights sum to 1, this function does not. It divides by the
sum of the weights, so it only requires that the sum is nonzero.
If you have only two points, use Q3Param2D_RRatio instead.
- params2D
- Array of 2D parameter points.
- weights
- Array of weights.
- numPoints
- How many elements there are in each array.
- result
- Address of point to set with the weighted combination.
Q3Param2D_Distance |
( float ) Q3Param2D_Distance ( const TQ3Param2D * _Nonnull p1, const TQ3Param2D * _Nonnull p2 );
Return Euclidean distance between two UV parameter points.
Available in inline form as Q3FastParam2D_Distance.
- p1
- Address of first point of interest.
- p2
- Address of second point of interest.
Q3Param2D_DistanceSquared |
( float ) Q3Param2D_DistanceSquared ( const TQ3Param2D * _Nonnull p1, const TQ3Param2D * _Nonnull p2 );
Return the squared Euclidean distance between two UV parameter points.
Available in inline form as Q3FastParam2D_DistanceSquared.
- p1
- Address of first point of interest.
- p2
- Address of second point of interest.
Q3Param2D_RRatio |
( TQ3Param2D * _Nonnull ) Q3Param2D_RRatio ( const TQ3Param2D * _Nonnull p1, const TQ3Param2D * _Nonnull p2, float r1, float r2, TQ3Param2D * _Nonnull result );
Return the point at ratio r2/(r1+r2) along the line segment is
parameter (UV) space from p1 to p2.
Put another way, this function gives you the weighted average of points
p1 and p2, with the weights given by r1 and r2. (Note that r1+r2 must
be nonzero.)
Available in inline form as Q3FastParam2D_RRatio.
- p1
- Address of one end of a line segment.
- p2
- Address of the other end of a line segment.
- r1
- Weight given to point p1.
- r2
- Weight given to point p2.
- result
- Address of point to set (may be the same as p1 and/or p2).
Q3Param2D_Set |
( TQ3Param2D * _Nonnull ) Q3Param2D_Set ( TQ3Param2D * _Nonnull param2D, float u, float v );
Set a 2D parameterization value (i.e., a UV coordinate).
Available in inline form as Q3FastParam2D_Set.
- param2D
- Address of param2D to set (may be nullptr).
- u
- U coordinate to set into param2D.
- v
- V coordinate to set into param2D.
Q3Param2D_Subtract |
( TQ3Vector2D * _Nonnull ) Q3Param2D_Subtract ( const TQ3Param2D * _Nonnull p1, const TQ3Param2D * _Nonnull p2, TQ3Vector2D * _Nonnull result );
Subtract 2D parametric point p2 from p1.
Available in inline form as Q3FastParam2D_Subtract.
- p1
- Address of a point.
- p2
- Address of point to subtract.
- result
- Address of a vector to set with (p1-p2).
Q3Param2D_Transform |
( TQ3Param2D * _Nonnull ) Q3Param2D_Transform ( const TQ3Param2D * _Nonnull param2D, const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3Param2D * _Nonnull result );
Transform a 2D parametric point by a 3x3 matrix.
- param2D
- Address of a point to transform.
- matrix3x3
- Address of a 3x3 transformation matrix.
- result
- Address of point to set (may be the same as point2D).
Q3Param2D_Vector2D_Add |
( TQ3Param2D * _Nonnull ) Q3Param2D_Vector2D_Add ( const TQ3Param2D * _Nonnull param2D, const TQ3Vector2D * _Nonnull vector2D, TQ3Param2D * _Nonnull result );
Add a 2D vector to a parametric (UV) point.
Available in inline form as Q3FastParam2D_Vector2D_Add.
- param2D
- Address of a 2D parametric point.
- vector2D
- Address of a vector to add.
- result
- Address of point to set (may be the same as param2D).
Q3Param2D_Vector2D_Subtract |
( TQ3Param2D * _Nonnull ) Q3Param2D_Vector2D_Subtract ( const TQ3Param2D * _Nonnull param2D, const TQ3Vector2D * _Nonnull vector2D, TQ3Param2D * _Nonnull result );
Subtract a 2D vector from a parametric (UV) point.
Available in inline form as Q3FastParam2D_Vector2D_Subtract.
- param2D
- Address of a 2D parametric point.
- vector2D
- Address of a vector to subtract.
- result
- Address of point to set (may be the same as param2D).
Q3Point2D_AffineComb |
( TQ3Point2D * _Nonnull ) Q3Point2D_AffineComb ( const TQ3Point2D * _Nonnull points2D, const float * _Nonnull weights, TQ3Uns32 numPoints, TQ3Point2D * _Nonnull result );
Return weighted combination of several 2D points.
Provide an array of points and a parallel array of weights, and
this function will compute the weighted combination.
Although the mathematical definition of an affine combination requires
that the weights sum to 1, this function does not. It divides by the
sum of the weights, so it only requires that the sum is nonzero.
If you have only two points, use Q3Point2D_RRatio instead.
- points2D
- Array of 2D points.
- weights
- Array of weights.
- numPoints
- How many elements there are in each array.
- result
- Address of point to set with the weighted combination.
Q3Point2D_CrossProductTri |
( float ) Q3Point2D_CrossProductTri ( const TQ3Point2D * _Nonnull p1, const TQ3Point2D * _Nonnull p2, const TQ3Point2D * _Nonnull p3 );
Return the length of the cross product of a triangle specified by
three 2D points, that is, of the vectors p2-p1 and p3-p2.
Available in inline form as Q3FastPoint2D_CrossProductTri.
- p1
- Address of one point in the triangle.
- p2
- Address of a second point in the triangle.
- p3
- Address of a third point in the triangle.
Q3Point2D_Distance |
( float ) Q3Point2D_Distance ( const TQ3Point2D * _Nonnull p1, const TQ3Point2D * _Nonnull p2 );
Return Euclidean distance between two 2D points.
Available in inline form as Q3FastPoint2D_Distance.
- p1
- Address of first point of interest.
- p2
- Address of second point of interest.
Q3Point2D_DistanceSquared |
( float ) Q3Point2D_DistanceSquared ( const TQ3Point2D * _Nonnull p1, const TQ3Point2D * _Nonnull p2 );
Return the squared Euclidean distance between two 2D points.
Available in inline form as Q3FastPoint2D_DistanceSquared.
- p1
- Address of first point of interest.
- p2
- Address of second point of interest.
Q3Point2D_RRatio |
( TQ3Point2D * _Nonnull ) Q3Point2D_RRatio ( const TQ3Point2D * _Nonnull p1, const TQ3Point2D * _Nonnull p2, float r1, float r2, TQ3Point2D * _Nonnull result );
Return the point at ratio r2/(r1+r2) along the line segment from p1 to p2.
Put another way, this function gives you the weighted average of points
p1 and p2, with the weights given by r1 and r2. (Note that r1+r2 must
be nonzero.)
NOTE: The QD3D docs claim that the ratio used is r1/(r1+r2), but
it was found by direct experimentation that the QD3D library (1.6)
in fact uses r2/(r1+r2) instead. This is as it should be, if r1 is
the weight of p1, and r2 is the weight of p2.
As usual, we do as QD3D does, not as the docs say.
Available in inline form as Q3FastPoint2D_RRatio.
- p1
- Address of one end of a line segment.
- p2
- Address of the other end of a line segment.
- r1
- Weight given to point p1.
- r2
- Weight given to point p2.
- result
- Address of point to set (may be the same as p1 and/or p2).
Q3Point2D_Set |
( TQ3Point2D * _Nonnull ) Q3Point2D_Set ( TQ3Point2D * _Nonnull point2D, float x, float y );
Set a 2D point.
Available in inline form as Q3FastPoint2D_Set.
- point2D
- Address of point to set (may be nullptr).
- x
- X coordinate to set into vector2D.
- y
- Y coordinate to set into vector2D.
Q3Point2D_Subtract |
( TQ3Vector2D * _Nonnull ) Q3Point2D_Subtract ( const TQ3Point2D * _Nonnull p1, const TQ3Point2D * _Nonnull p2, TQ3Vector2D * _Nonnull result );
Subtract the 2D point p2 from p1.
Available in inline form as Q3FastPoint2D_Subtract.
- p1
- Address of a point.
- p2
- Address of point to subtract.
- result
- Address of a vector to set with (p1-p2).
Q3Point2D_To2DTransformArray |
( TQ3Status ) Q3Point2D_To2DTransformArray ( const TQ3Point2D * _Nonnull inPoints2D, const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3Point2D * _Nonnull outPoints2D, TQ3Uns32 numPoints, TQ3Uns32 inStructSize, TQ3Uns32 outStructSize );
Transform an array of 2D points by a 3x3 matrix.
When you have many points to transform, this is a more efficient
alternative to calling Q3Point2D_Transform repeatedly.
- inPoints2D
- Array of 2D points to transform.
- matrix3x3
- Transformation matrix.
- outPoints2D
- Array of points to receive output (may be the same as inPoints2D).
- numPoints
- How many points are in each array.
- inStructSize
- Size of one element of the input array, typically sizeof(TQ3Point2D).
- outStructSize
- Size of one element of the output array, typically sizeof(TQ3Point2D).
Q3Point2D_To3D |
( TQ3RationalPoint3D * _Nonnull ) Q3Point2D_To3D ( const TQ3Point2D * _Nonnull point2D, TQ3RationalPoint3D * _Nonnull result );
Convert 2D point to rational 3D, setting w to 1.
The Apple version incorrectly declares the type of 'result' to
be TQ3Point3D rather than TQ3RationalPoint3D. At a binary level
there is no difference, but at the source code level the Apple
version forces the use of the incorrect type or type casting.
Available in inline form as Q3FastPoint2D_To3D.
- point2D
- Address of 2D point to convert.
- result
- Address of 3D rational point to set.
Q3Point2D_To3DTransformArray |
( TQ3Status ) Q3Point2D_To3DTransformArray ( const TQ3Point2D * _Nonnull inPoints2D, const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3RationalPoint3D * _Nonnull outRationalPoints3D, TQ3Uns32 numPoints, TQ3Uns32 inStructSize, TQ3Uns32 outStructSize );
Transform an array of 2D points by a 3x3 matrix into 3D rational points.
When you have many vectors to transform, this is a more efficient
alternative to calling Q3Point2D_To3D and Q3RationalPoint3D_Transform repeatedly.
- inPoints2D
- Array of 2D points to transform.
- matrix3x3
- Transformation matrix.
- outRationalPoints3D
- Array of points to receive output.
- numPoints
- How many points are in each array.
- inStructSize
- Size of one element of the input array, typically sizeof(TQ3Point2D).
- outStructSize
- Size of one element of the output array, typically sizeof(TQ3RationalPoint3D).
Q3Point2D_ToPolar |
( TQ3PolarPoint * _Nonnull ) Q3Point2D_ToPolar ( const TQ3Point2D * _Nonnull point2D, TQ3PolarPoint * _Nonnull result );
Convert 2D cartesian point to polar coordinates.
The angle (theta) here is measured counter-clockwise from the +x axis.
- point2D
- Address of 2D point to convert.
- result
- Address of polar point to set.
Q3Point2D_Transform |
( TQ3Point2D * _Nonnull ) Q3Point2D_Transform ( const TQ3Point2D * _Nonnull point2D, const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3Point2D * _Nonnull result );
Transform a 2D point by a 3x3 matrix.
- point2D
- Address of a point to transform.
- matrix3x3
- Address of a 3x3 transformation matrix.
- result
- Address of point to set (may be the same as point2D).
Q3Point2D_Vector2D_Add |
( TQ3Point2D * _Nonnull ) Q3Point2D_Vector2D_Add ( const TQ3Point2D * _Nonnull point2D, const TQ3Vector2D * _Nonnull vector2D, TQ3Point2D * _Nonnull result );
Add a 2D vector to a point.
Available in inline form as Q3FastPoint2D_Vector2D_Add.
- point2D
- Address of a point.
- vector2D
- Address of a vector to add.
- result
- Address of point to set (may be the same as point2D).
Q3Point2D_Vector2D_Subtract |
( TQ3Point2D * _Nonnull ) Q3Point2D_Vector2D_Subtract ( const TQ3Point2D * _Nonnull point2D, const TQ3Vector2D * _Nonnull vector2D, TQ3Point2D * _Nonnull result );
Subtract a 2D vector from a point.
Available in inline form as Q3FastPoint2D_Vector2D_Subtract.
- point2D
- Address of a point.
- vector2D
- Address of a vector to subtract.
- result
- Address of point to set (may be the same as point2D).
Q3Point3D_AffineComb |
( TQ3Point3D * _Nonnull ) Q3Point3D_AffineComb ( const TQ3Point3D * _Nonnull points3D, const float * _Nonnull weights, TQ3Uns32 numPoints, TQ3Point3D * _Nonnull result );
Return weighted combination of several 3D points.
Provide an array of points and a parallel array of weights, and
this function will compute the weighted combination.
Although the mathematical definition of an affine combination requires
that the weights sum to 1, this function does not. It divides by the
sum of the weights, so it only requires that the sum is nonzero.
If you have only two points, use Q3Point3D_RRatio instead.
- points3D
- Array of 3D points.
- weights
- Array of weights.
- numPoints
- How many elements there are in each array.
- result
- Address of point to set with the weighted combination.
Q3Point3D_CrossProductTri |
( TQ3Vector3D * _Nonnull ) Q3Point3D_CrossProductTri ( const TQ3Point3D * _Nonnull p1, const TQ3Point3D * _Nonnull p2, const TQ3Point3D * _Nonnull p3, TQ3Vector3D * _Nonnull result );
Return the cross product of triangle triangle defined by three
3D points, that is, of the vectors p2-p1 and p3-p2.
Available in inline form as Q3FastPoint3D_CrossProductTri.
- p1
- Address of one point in the triangle.
- p2
- Address of a second point in the triangle.
- p3
- Address of a third point in the triangle.
- result
- Address of vector to set with cross product (p2-p1) x (p3-p2).
Q3Point3D_Distance |
( float ) Q3Point3D_Distance ( const TQ3Point3D * _Nonnull p1, const TQ3Point3D * _Nonnull p2 );
Return Euclidean distance between two 3D points.
Available in inline form as Q3FastPoint3D_Distance.
- p1
- Address of first point of interest.
- p2
- Address of second point of interest.
Q3Point3D_DistanceSquared |
( float ) Q3Point3D_DistanceSquared ( const TQ3Point3D * _Nonnull p1, const TQ3Point3D * _Nonnull p2 );
Return the squared Euclidean distance between two 3D points.
Available in inline form as Q3FastPoint3D_DistanceSquared.
- p1
- Address of first point of interest.
- p2
- Address of second point of interest.
Q3Point3D_RRatio |
( TQ3Point3D * _Nonnull ) Q3Point3D_RRatio ( const TQ3Point3D * _Nonnull p1, const TQ3Point3D * _Nonnull p2, float r1, float r2, TQ3Point3D * _Nonnull result );
Return the point at ratio r2/(r1+r2) along the line segment from p1 to p2.
Put another way, this function gives you the weighted average of points
p1 and p2, with the weights given by r1 and r2. (Note that r1+r2 must
be nonzero.)
NOTE: The QD3D docs claim that the ratio used is r1/(r1+r2), but
it was found by direct experimentation that the QD3D library (1.6)
in fact uses r2/(r1+r2) instead. This is as it should be, if r1 is
the weight of p1, and r2 is the weight of p2.
As usual, we do as QD3D does, not as the docs say.
Available in inline form as Q3FastPoint3D_RRatio.
- p1
- Address of one end of a line segment.
- p2
- Address of the other end of a line segment.
- r1
- Weight given to point p1.
- r2
- Weight given to point p2.
- result
- Address of point to set (may be the same as p1 and/or p2).
Q3Point3D_Set |
( TQ3Point3D * _Nonnull ) Q3Point3D_Set ( TQ3Point3D * _Nonnull point3D, float x, float y, float z );
Set a 3D point.
Available in inline form as Q3FastPoint3D_Set.
- point3D
- Address of point to set (may be nullptr).
- x
- X coordinate to set into point3D.
- y
- Y coordinate to set into point3D.
- z
- Z coordinate to set into point3D.
Q3Point3D_Subtract |
( TQ3Vector3D * _Nonnull ) Q3Point3D_Subtract ( const TQ3Point3D * _Nonnull p1, const TQ3Point3D * _Nonnull p2, TQ3Vector3D * _Nonnull result );
Subtract 3D point p2 from p1.
Available in inline form as Q3FastPoint3D_Subtract.
- p1
- Address of a point.
- p2
- Address of a point to subtract.
- result
- Address of point to set (may be the same as p1 and/or p2).
Q3Point3D_To3DTransformArray |
( TQ3Status ) Q3Point3D_To3DTransformArray ( const TQ3Point3D * _Nullable inPoints3D, const TQ3Matrix4x4 * _Nonnull matrix4x4, TQ3Point3D * _Nullable outPoints3D, TQ3Uns32 numPoints, TQ3Uns32 inStructSize, TQ3Uns32 outStructSize );
Transform an array of 3D points by a 4x4 matrix.
When you have many points to transform, this is a more efficient
alternative to calling Q3Point3D_Transform repeatedly.
- inPoints3D
- Array of 3D points to transform. Must not be NULL unless numPoints == 0.
- matrix4x4
- Transformation matrix.
- outPoints3D
- Array of points to receive output (may be the same as inPoints3D).
- numPoints
- How many points are in each array.
- inStructSize
- Size of one element of the input array, typically sizeof(TQ3Point3D).
- outStructSize
- Size of one element of the output array, typically sizeof(TQ3Point3D).
Q3Point3D_To4D |
( TQ3RationalPoint4D * _Nonnull ) Q3Point3D_To4D ( const TQ3Point3D * _Nonnull point3D, TQ3RationalPoint4D * _Nonnull result );
Convert 3D point to rational 4D, setting w to 1.
Available in inline form as Q3FastPoint3D_To4D.
- point3D
- Address of 3D point to convert.
- result
- Address of rational 4D point to set.
Q3Point3D_To4DTransformArray |
( TQ3Status ) Q3Point3D_To4DTransformArray ( const TQ3Point3D * _Nonnull inPoints3D, const TQ3Matrix4x4 * _Nonnull matrix4x4, TQ3RationalPoint4D * _Nonnull outRationalPoints4D, TQ3Uns32 numPoints, TQ3Uns32 inStructSize, TQ3Uns32 outStructSize );
Transform an array of 3D points by a 4x4 matrix into 4D rational points.
When you have many vectors to transform, this is a more efficient
alternative to calling Q3Point3D_To4D and Q3RationalPoint4D_Transform repeatedly.
- inPoints3D
- Array of 3D points to transform.
- matrix4x4
- Transformation matrix.
- outRationalPoints4D
- Array of points to receive output.
- numPoints
- How many points are in each array.
- inStructSize
- Size of one element of the input array, typically sizeof(TQ3Point3D).
- outStructSize
- Size of one element of the output array, typically sizeof(TQ3RationalPoint4D).
Q3Point3D_ToSpherical |
( TQ3SphericalPoint * _Nonnull ) Q3Point3D_ToSpherical ( const TQ3Point3D * _Nonnull point3D, TQ3SphericalPoint * _Nonnull result );
Convert 3D cartesian point to spherical coordinates.
- point3D
- Address of 3D cartesian point to convert.
- result
- Address of spherical-coordinates point to set.
Q3Point3D_Transform |
( TQ3Point3D * _Nonnull ) Q3Point3D_Transform ( const TQ3Point3D * _Nonnull point3D, const TQ3Matrix4x4 * _Nonnull matrix4x4, TQ3Point3D * _Nonnull result );
Transform a 3D point by a 4x4 matrix.
- point3D
- Address of a point to transform.
- matrix4x4
- Address of a 4x4 transformation matrix.
- result
- Address of point to set (may be the same as point3D).
Q3Point3D_TransformQuaternion |
( TQ3Point3D * _Nonnull ) Q3Point3D_TransformQuaternion ( const TQ3Point3D * _Nonnull point3D, const TQ3Quaternion * _Nonnull quaternion, TQ3Point3D * _Nonnull result );
Transform a 3D point by a quaternion.
Note that for correct results, the quaternion should be normalized.
- point3D
- Address of a point to transform.
- quaternion
- Address of a quaternion to transform by.
- result
- Address of a point to set (may be the same as point3D).
Q3Point3D_Vector3D_Add |
( TQ3Point3D * _Nonnull ) Q3Point3D_Vector3D_Add ( const TQ3Point3D * _Nonnull point3D, const TQ3Vector3D * _Nonnull vector3D, TQ3Point3D * _Nonnull result );
Add a 3D vector to a point.
Available in inline form as Q3FastPoint3D_Vector3D_Add.
- point3D
- Address of a point.
- vector3D
- Address of a vector to add.
- result
- Address of point to set (may be the same as point3D).
Q3Point3D_Vector3D_Subtract |
( TQ3Point3D * _Nonnull ) Q3Point3D_Vector3D_Subtract ( const TQ3Point3D * _Nonnull point3D, const TQ3Vector3D * _Nonnull vector3D, TQ3Point3D * _Nonnull result );
Subtract 3D vector from point.
Available in inline form as Q3FastPoint3D_Vector3D_Subtract.
- point3D
- Address of a point.
- vector3D
- Address of a vector to subtract.
- result
- Address of point to set (may be the same as point3D).
Q3PolarPoint_Set |
( TQ3PolarPoint * _Nonnull ) Q3PolarPoint_Set ( TQ3PolarPoint * _Nonnull polarPoint, float r, float theta );
Set a 2D polar-coordinates point.
Available in inline form as Q3FastPolarPoint_Set.
- polarPoint
- Address of point to set (may be nullptr).
- r
- Radius coordinate to set into polarPoint.
- theta
- Angle coordinate (in radians) to set into polarPoint.
Q3PolarPoint_ToPoint2D |
( TQ3Point2D * _Nonnull ) Q3PolarPoint_ToPoint2D ( const TQ3PolarPoint * _Nonnull polarPoint, TQ3Point2D * _Nonnull result );
Convert 2D polar point to cartesian coordinates.
The angle (theta) here is measured counter-clockwise from the +x axis.
Available in inline form as Q3FastPolarPoint_ToPoint2D.
- polarPoint
- Address of polar point to convert.
- result
- Address of 2D cartesian point to set.
Q3Quaternion_Copy |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_Copy ( const TQ3Quaternion * _Nonnull quaternion, TQ3Quaternion * _Nonnull result );
Copy a quaternion.
Available in inline form as Q3FastQuaternion_Copy.
- quaternion
- Address of source quaternion.
- result
- Address of destination quaternion (may be the same as the first parameter).
Q3Quaternion_Dot |
( float ) Q3Quaternion_Dot ( const TQ3Quaternion * _Nonnull q1, const TQ3Quaternion * _Nonnull q2 );
Return the dot product of q1 and q2.
Available in inline form as Q3FastQuaternion_Dot.
- q1
- Address of one quaternion.
- q2
- Address of another quaternion (may be the same as q1).
Q3Quaternion_GetAxisAndAngle |
( TQ3Vector3D * _Nonnull ) Q3Quaternion_GetAxisAndAngle ( const TQ3Quaternion * _Nonnull quaternion, TQ3Vector3D * _Nonnull outAxis, float * _Nonnull outAngle );
Get the rotation axis and/or angle represented by a quaternion.
Note that for correct results, the quaternion should be normalized.
If the quaternion represents a null rotation, then outAngle will be
set to 0.0 and outAxis will be set to <0, 1, 0> (since in this case
the rotation axis is undefined, but we want to always give you a
valid axis).
The returned angle in radians will be in the range [0, 2*pi].
Either outAxis or outAngle may be null if you are not interested in
that result. (You could even pass null for both, but that would be
rather pointless.)
- quaternion
- Address of a quaternion to inspect.
- outAxis
- Address of a vector to set to the rotation axis (may be null).
- outAngle
- Address of a float to set to the rotation angle (may be null).
Q3Quaternion_InterpolateFast |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_InterpolateFast ( const TQ3Quaternion * _Nonnull q1, const TQ3Quaternion * _Nonnull q2, float t, TQ3Quaternion * _Nonnull result );
Compute a straight linear interpolation between two quaternions.
This does a true linear, not spherical, interpolation between
q1 and q2. It's fast, but not very proper for most uses.
The result is automatically normalized, so there is no need to
do so yourself.
- q1
- Address of first quaternion.
- q2
- Address of second quaternion.
- t
- Fraction (0-1) of the way from q1 to q2.
- result
- Address of quaternion to set (may be the same as q1 and/or q2).
Q3Quaternion_InterpolateLinear |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_InterpolateLinear ( const TQ3Quaternion * _Nonnull q1, const TQ3Quaternion * _Nonnull q2, float t, TQ3Quaternion * _Nonnull result );
Compute a spherical linear interpolation between two quaternions.
Despite the name, this function does a SLERP (spherical linear
interpolation) from q1 to q2.
It falls back on a straight linear interpolation only when the
cosine of the angle between them is less than 0.01.
The cut-off point was chosen arbitrarily, and may not match
that of QD3D.
- q1
- Address of first quaternion.
- q2
- Address of second quaternion.
- t
- Fraction (0-1) of the way from q1 to q2.
- result
- Address of quaternion to set (may be the same as q1 and/or q2).
Q3Quaternion_Invert |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_Invert ( const TQ3Quaternion * _Nonnull quaternion, TQ3Quaternion * _Nonnull result );
Invert a quaternion.
For correct results, the quaternion should be normalized
before inverting.
Available in inline form as Q3FastQuaternion_Invert.
- quaternion
- Address of a quaternion to invert.
- result
- Address of quaternion to set (may be the same as the first parameter).
Q3Quaternion_IsIdentity |
( TQ3Boolean ) Q3Quaternion_IsIdentity ( const TQ3Quaternion * _Nonnull quaternion );
Return whether a quaternion is (roughly) the identity,
i.e., (1,0,0,0).
Values for x, y, and z are considered close enough to 0
if they are within FLT_EPSILON (a small number).
For correct results, the quaternion should first be normalized.
- quaternion
- Address of quaternion to test.
Q3Quaternion_MatchReflection |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_MatchReflection ( const TQ3Quaternion * _Nonnull q1, const TQ3Quaternion * _Nonnull q2, TQ3Quaternion * _Nonnull result );
Set result to either q1 or -q1, whichever produces a positive dot
product with q2 (i.e., whichever is "closer" to q2 in orientation).
- q1
- Address of source quaternion.
- q2
- Address of quaternion to match.
- result
- Address of quaternion to set (may be the same as q1 and/or q2).
Q3Quaternion_Multiply |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_Multiply ( const TQ3Quaternion * _Nonnull q1, const TQ3Quaternion * _Nonnull q2, TQ3Quaternion * _Nonnull result );
Compute the product of two quaternions.
This is a very useful operation, since the rotation represented
by q1*q2 is exactly the same as rotating by q1 and then by q2.
- q1
- Address of first quaternion.
- q2
- Address of second quaternion.
- result
- Address of quaternion to set (may be the same as q1 and/or q2).
Q3Quaternion_Normalize |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_Normalize ( const TQ3Quaternion * _Nonnull quaternion, TQ3Quaternion * _Nonnull result );
Scale a quaternion to length 1.
This is often needed when combining or interpolating between
quaternions, to keep accumulated error from causing your
quaternion values to "blow up".
Available in inline form as Q3FastQuaternion_Normalize.
- quaternion
- Address of a quaternion to normalize.
- result
- Address of quaternion to set (may be the same as the first parameter).
Q3Quaternion_Set |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_Set ( TQ3Quaternion * _Nonnull quaternion, float w, float x, float y, float z );
Set a quaternion with its individual w, x, y, and z components.
Available in inline form as Q3FastQuaternion_Set.
- quaternion
- Address of a quaternion to set.
- w
- Value for w component.
- x
- Value for x component.
- y
- Value for y component.
- z
- Value for z component.
Q3Quaternion_SetIdentity |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_SetIdentity ( TQ3Quaternion * _Nonnull quaternion );
Set a quaternion to the identity value (1,0,0,0).
Available in inline form as Q3FastQuaternion_SetIdentity.
- quaternion
- Address of a quaternion to set.
Q3Quaternion_SetMatrix |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_SetMatrix ( TQ3Quaternion * _Nonnull quaternion, const TQ3Matrix4x4 * _Nonnull matrix4x4 );
Set a quaternion from a 4x4 rotation matrix.
Note: The QD3D implementation of this function appears to be buggy.
This can be demonstrated by starting with an arbitrary
quaternion, converting to a matrix, then converting back (with
this function).
QD3D's result is something ridiculous; in Quesa, this function
returns the original quaternion (or something equivalent).
- quaternion
- Address of a quaternion to set.
- matrix4x4
- Address of a rotation matrix to imitate.
Q3Quaternion_SetRotateAboutAxis |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_SetRotateAboutAxis ( TQ3Quaternion * _Nonnull quaternion, const TQ3Vector3D * _Nonnull axis, float angle );
Set quaternion to rotate about arbitrary axis.
Note that for correct results, the axis should be normalized
(i.e. have length = 1).
- quaternion
- Address of a quaternion to set.
- axis
- Address of a 3D vector to use as the rotation axis.
- angle
- Angle to rotate (in radians).
Q3Quaternion_SetRotateVectorToVector |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_SetRotateVectorToVector ( TQ3Quaternion * _Nonnull quaternion, const TQ3Vector3D * _Nonnull v1, const TQ3Vector3D * _Nonnull v2 );
Set a quaternion to rotate vector 'v1' to 'v2'.
Note that for correct results, both vectors should be normalized
(i.e. have length = 1).
- quaternion
- Address of a quaternion to set.
- v1
- Address of "starting" vector.
- v2
- Address of "ending" vector.
Q3Quaternion_SetRotate_X |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_SetRotate_X ( TQ3Quaternion * _Nonnull quaternion, float angle );
Set a quaternion to rotate about the X axis.
- quaternion
- Address of a quaternion to set.
- angle
- Angle to rotate (in radians).
Q3Quaternion_SetRotate_XYZ |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_SetRotate_XYZ ( TQ3Quaternion * _Nonnull quaternion, float xAngle, float yAngle, float zAngle );
Set a quaternion to rotate about the X, Y, and Z axes (in that order).
This order of rotations is rarely useful, but it's kept for backwards
compatibility with QD3D.
- quaternion
- Address of a quaternion to set.
- xAngle
- Angle to rotate about the X axis (in radians).
- yAngle
- Angle to rotate about the Y axis (in radians).
- zAngle
- Angle to rotate about the Z axis (in radians).
Q3Quaternion_SetRotate_Y |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_SetRotate_Y ( TQ3Quaternion * _Nonnull quaternion, float angle );
Set a quaternion to rotate about the Y axis.
- quaternion
- Address of a quaternion to set.
- angle
- Angle to rotate (in radians).
Q3Quaternion_SetRotate_Z |
( TQ3Quaternion * _Nonnull ) Q3Quaternion_SetRotate_Z ( TQ3Quaternion * _Nonnull quaternion, float angle );
Set a quaternion to rotate about the Z axis.
- quaternion
- Address of a quaternion to set.
- angle
- Angle to rotate (in radians).
Q3RationalPoint3D_AffineComb |
( TQ3RationalPoint3D * _Nonnull ) Q3RationalPoint3D_AffineComb ( const TQ3RationalPoint3D * _Nonnull rationalPoints3D, const float * _Nonnull weights, TQ3Uns32 numPoints, TQ3RationalPoint3D * _Nonnull result );
Compute the weighted combination of several 3D rational points.
Although the mathematical definition of an affine combination requires
that the weights sum to 1, this function does not. It divides by the
sum of the weights, so it only requires that the sum is nonzero.
- rationalPoints3D
- Array of 3D rational points.
- weights
- Array of weights.
- numPoints
- How many elements there are in each array.
- result
- Address of point to set with the weighted combination.
Q3RationalPoint3D_Distance |
( float ) Q3RationalPoint3D_Distance ( const TQ3RationalPoint3D * _Nonnull p1, const TQ3RationalPoint3D * _Nonnull p2 );
Returns the Euclidian distance between two rational 3D points.
This operation makes no sense mathematically, but is included
for backwards compatibility with QD3D.
Available in inline form as Q3FastRationalPoint3D_Distance.
- p1
- Address of first point of interest.
- p2
- Address of second point of interest.
Q3RationalPoint3D_DistanceSquared |
( float ) Q3RationalPoint3D_DistanceSquared ( const TQ3RationalPoint3D * _Nonnull p1, const TQ3RationalPoint3D * _Nonnull p2 );
Returns the squared Euclidian distance between two rational 3D points.
This operation makes no sense mathematically, but is included
for backwards compatibility with QD3D.
Available in inline form as Q3FastRationalPoint3D_DistanceSquared.
- p1
- Address of first point of interest.
- p2
- Address of second point of interest.
Q3RationalPoint3D_Set |
( TQ3RationalPoint3D * _Nonnull ) Q3RationalPoint3D_Set ( TQ3RationalPoint3D * _Nonnull rationalPoint3D, float x, float y, float w );
Set a 3D rational point (x,y,w).
Available in inline form as Q3FastRationalPoint3D_Set.
- rationalPoint3D
- Address of rational point to set (may be nullptr).
- x
- X coordinate to set into rationalPoint3D.
- y
- Y coordinate to set into rationalPoint3D.
- w
- W coordinate to set into rationalPoint3D.
Q3RationalPoint3D_To2D |
( TQ3Point2D * _Nonnull ) Q3RationalPoint3D_To2D ( const TQ3RationalPoint3D * _Nonnull rationalPoint3D, TQ3Point2D * _Nonnull result );
Convert rational 3D point to 2D, dividing by w.
Available in inline form as Q3FastRationalPoint3D_To2D.
- rationalPoint3D
- Address of rational 3D point to convert.
- result
- Address of 2D point to set.
Q3RationalPoint3D_To3DTransformArray |
( TQ3Status ) Q3RationalPoint3D_To3DTransformArray ( const TQ3RationalPoint3D * _Nonnull inRationalPoints3D, const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3RationalPoint3D * _Nonnull outRationalPoints3D, TQ3Uns32 numPoints, TQ3Uns32 inStructSize, TQ3Uns32 outStructSize );
Transform an array of 3D rational points by a 3x3 matrix.
When you have many points to transform, this is a more efficient
alternative to calling Q3RationalPoint3D_Transform repeatedly.
- inRationalPoints3D
- Array of 3D rational points to transform.
- matrix3x3
- Transformation matrix.
- outRationalPoints3D
- Array of points to receive output (may be the same as inRationalPoints3D).
- numPoints
- How many points are in each array.
- inStructSize
- Size of one element of the input array, typically sizeof(TQ3RationalPoint3D).
- outStructSize
- Size of one element of the output array, typically sizeof(TQ3RationalPoint3D).
Q3RationalPoint3D_ToVector2D |
( TQ3Vector2D * _Nonnull ) Q3RationalPoint3D_ToVector2D ( const TQ3RationalPoint3D * _Nonnull rationalPoint3D, TQ3Vector2D * _Nonnull result );
Convert 3D rational point to 2D vector, discarding w.
Available in inline form as Q3FastRationalPoint3D_ToVector2D.
- rationalPoint3D
- Address of 3D rational point to convert.
- result
- Address of 2D vector to set.
Q3RationalPoint3D_Transform |
( TQ3RationalPoint3D * _Nonnull ) Q3RationalPoint3D_Transform ( const TQ3RationalPoint3D * _Nonnull rationalPoint3D, const TQ3Matrix3x3 * _Nonnull matri3x3, TQ3RationalPoint3D * _Nonnull result );
Transform a 3D rational point by 3x3 matrix.
- rationalPoint3D
- Address of a point to transform.
- matrix3x3
- Address of a 3x3 transformation matrix.
- result
- Address of point to set (may be the same as rationalPoint3D).
Q3RationalPoint4D_AffineComb |
( TQ3RationalPoint4D * _Nonnull ) Q3RationalPoint4D_AffineComb ( const TQ3RationalPoint4D * _Nonnull rationalPoints4D, const float * _Nonnull weights, TQ3Uns32 numPoints, TQ3RationalPoint4D * _Nonnull result );
Compute the weighted combination of several 4D rational points.
Although the mathematical definition of an affine combination requires
that the weights sum to 1, this function does not. It divides by the
sum of the weights, so it only requires that the sum is nonzero.
- rationalPoints4D
- Array of 4D rational points.
- weights
- Array of weights.
- numPoints
- How many elements there are in each array.
- result
- Address of point to set with the weighted combination.
Q3RationalPoint4D_Distance |
( float ) Q3RationalPoint4D_Distance ( const TQ3RationalPoint4D * _Nonnull p1, const TQ3RationalPoint4D * _Nonnull p2 );
Returns the Euclidian distance between two rational 4D points.
This operation makes no sense mathematically, but is included
for backwards compatibility with QD3D.
Available in inline form as Q3FastRationalPoint4D_Distance.
- p1
- Address of first point of interest.
- p2
- Address of second point of interest.
Q3RationalPoint4D_DistanceSquared |
( float ) Q3RationalPoint4D_DistanceSquared ( const TQ3RationalPoint4D * _Nonnull p1, const TQ3RationalPoint4D * _Nonnull p2 );
Returns the squared Euclidian distance between two rational 4D points.
This operation makes no sense mathematically, but is included
for backwards compatibility with QD3D.
Available in inline form as Q3FastRationalPoint4D_DistanceSquared.
- p1
- Address of first point of interest.
- p2
- Address of second point of interest.
Q3RationalPoint4D_RRatio |
( TQ3RationalPoint4D * _Nonnull ) Q3RationalPoint4D_RRatio ( const TQ3RationalPoint4D * _Nonnull p1, const TQ3RationalPoint4D * _Nonnull p2, float r1, float r2, TQ3RationalPoint4D * _Nonnull result );
Return the point at ratio r2/(r1+r2) along the line segment from p1 to p2.
Put another way, this function gives you the weighted average of points
p1 and p2, with the weights given by r1 and r2. (Note that r1+r2 must
be nonzero.)
NOTE: The QD3D docs claim that the ratio used is r1/(r1+r2), but
it was found by direct experimentation that the QD3D library (1.6)
in fact uses r2/(r1+r2) instead. This is as it should be, if r1 is
the weight of p1, and r2 is the weight of p2.
As usual, we do as QD3D does, not as the docs say.
Available in inline form as Q3FastRationalPoint4D_RRatio.
- p1
- Address of one end of a line segment.
- p2
- Address of the other end of a line segment.
- r1
- Weight given to point p1.
- r2
- Weight given to point p2.
- result
- Address of point to set (may be the same as p1 and/or p2).
Q3RationalPoint4D_Set |
( TQ3RationalPoint4D * _Nonnull ) Q3RationalPoint4D_Set ( TQ3RationalPoint4D * _Nonnull rationalPoint4D, float x, float y, float z, float w );
Set a 4D rational point (x,y,z,w).
Available in inline form as Q3FastRationalPoint4D_Set.
- rationalPoint4D
- Address of rational point to set.
- x
- X coordinate to set into rationalPoint4D.
- y
- Y coordinate to set into rationalPoint4D.
- z
- Z coordinate to set into rationalPoint4D.
Q3RationalPoint4D_To3D |
( TQ3Point3D * _Nonnull ) Q3RationalPoint4D_To3D ( const TQ3RationalPoint4D * _Nonnull rationalPoint4D, TQ3Point3D * _Nonnull result );
Convert rational 4D point to 3D, dividing by w.
Available in inline form as Q3FastRationalPoint4D_To3D.
- rationalPoint4D
- Address of rational 4D point to convert.
- result
- Address of 3D point to set.
Q3RationalPoint4D_To4DTransformArray |
( TQ3Status ) Q3RationalPoint4D_To4DTransformArray ( const TQ3RationalPoint4D * _Nonnull inRationalPoints4D, const TQ3Matrix4x4 * _Nonnull matrix4x4, TQ3RationalPoint4D * _Nonnull outRationalPoints4D, TQ3Uns32 numPoints, TQ3Uns32 inStructSize, TQ3Uns32 outStructSize );
Transform an array of 4D points by a 4x4 matrix.
When you have many points to transform, this is a more efficient
alternative to calling Q3RationalPoint4D_Transform repeatedly.
- inRationalPoints4D
- Array of 4D points to transform.
- matrix4x4
- Transformation matrix.
- outRationalPoints4D
- Array of points to receive output (may be the same as inRationalPoints4D).
- numPoints
- How many points are in each array.
- inStructSize
- Size of one element of the input array, typically sizeof(TQ3RationalPoint4D).
- outStructSize
- Size of one element of the output array, typically sizeof(TQ3RationalPoint4D).
Q3RationalPoint4D_ToVector3D |
( TQ3Vector3D * _Nonnull ) Q3RationalPoint4D_ToVector3D ( const TQ3RationalPoint4D * _Nonnull rationalPoint4D, TQ3Vector3D * _Nonnull result );
Convert 4D rational point to 3D vector, discarding w.
Available in inline form as Q3FastRationalPoint4D_ToVector3D.
- rationalPoint4D
- Address of 4D rational point to convert.
- result
- Address of 3D vector to set.
Q3RationalPoint4D_Transform |
( TQ3RationalPoint4D * _Nonnull ) Q3RationalPoint4D_Transform ( const TQ3RationalPoint4D * _Nonnull rationalPoint4D, const TQ3Matrix4x4 * _Nonnull matrix4x4, TQ3RationalPoint4D * _Nonnull result );
Transform a 4D rational point by a 4x4 matrix.
- rationalPoint4D
- Address of a point to transform.
- matrix4x4
- Address of a 4x4 transformation matrix.
- result
- Address of point to set (may be the same as rationalPoint4D).
Q3Ray3D_IntersectBoundingBox |
( TQ3Boolean ) Q3Ray3D_IntersectBoundingBox ( const TQ3Ray3D * _Nonnull theRay, const TQ3BoundingBox * _Nonnull theBounds, TQ3Point3D * _Nonnull hitPoint );
Test a ray for intersection against a bounding box. If an
intersection occurs, the point of intersection is returned.
The direction vector of the ray must be normalised.
- theRay
- The ray to test.
- theBounds
- The bounding box to test against.
- hitPoint
- Receives the intersection point, if found.
Q3Ray3D_IntersectSphere |
( TQ3Boolean ) Q3Ray3D_IntersectSphere ( const TQ3Ray3D * _Nonnull theRay, const TQ3Sphere * _Nonnull theSphere, TQ3Point3D * _Nonnull hitPoint );
Test a ray for intersection against a sphere, and return the point
of intersection if found.
The direction vector of the ray must be normalised.
- theRay
- The ray to test.
- theSphere
- The sphere to test against.
- hitPoint
- Receives the intersection point, if found.
Q3Ray3D_IntersectTriangle |
( TQ3Boolean ) Q3Ray3D_IntersectTriangle ( const TQ3Ray3D * _Nonnull theRay, const TQ3Point3D * _Nonnull point1, const TQ3Point3D * _Nonnull point2, const TQ3Point3D * _Nonnull point3, TQ3Boolean cullBackfacing, TQ3Param3D * _Nonnull hitPoint );
Test a ray for intersection against a triangle formed by three
points. If an intersection occurs, returns the barycentric
coordinates of the point of intersection and the parameter along
the ray.
Triangles may optionally be subject to backface culling, in
which case a hit on the reverse side of the triangle will fail
to result in an intersection.
The u and v members of hitPoint can be used to express the point of
intersection in terms of the vertices of the triangles, using
barycentric coordinates, as follows:
t = (1.0f - hitPoint.u - hitPoint.v); x = (point1.x * t) + (point2.x * hitPoint.u) + (point3.x * hitPoint.v); y = (point1.y * t) + (point2.y * hitPoint.u) + (point3.y * hitPoint.v); z = (point1.z * t) + (point2.z * hitPoint.u) + (point3.z * hitPoint.v);
- theRay
- The ray to test.
- point1
- The first triangle vertex.
- point2
- The second triangle vertex.
- point3
- The third triangle vertex.
- cullBackfacing
- Controls if back-facing triangles should be skipped.
- hitPoint
- Receives the barycentric coordinates of the intersection, and the multiple of the direction vector that reaches the intersection.
Q3SphericalPoint_Set |
( TQ3SphericalPoint * _Nonnull ) Q3SphericalPoint_Set ( TQ3SphericalPoint * _Nonnull sphericalPoint, float rho, float theta, float phi );
Set a 3D spherical-coordinates point.
Available in inline form as Q3FastSphericalPoint_Set.
- sphericalPoint
- Address of point to set (may be nullptr).
- rho
- Rho coordinate to set into sphericalPoint.
- theta
- Theta coordinate to set into sphericalPoint.
- phi
- Phi coordinate to set into sphericalPoint.
Q3SphericalPoint_ToPoint3D |
( TQ3Point3D * _Nonnull ) Q3SphericalPoint_ToPoint3D ( const TQ3SphericalPoint * _Nonnull sphericalPoint, TQ3Point3D * _Nonnull result );
Convert 3D spherical point to cartesian coordinates.
- sphericalPoint
- Address of spherical-coordinates point to convert.
- result
- Address of 3D cartesian point to set.
Q3Triangle_CrossProductArray |
( TQ3Status ) Q3Triangle_CrossProductArray ( TQ3Uns32 numTriangles, const TQ3Uns8 * _Nullable usageFlags, const TQ3Uns32 * _Nonnull theIndices, const TQ3Point3D * _Nonnull thePoints, TQ3Vector3D * _Nonnull theNormals );
Calculate an array of triangle normals.
Triangles are specified as a contiguous array of triangle indices,
and a contiguous array of points. The result is a contiguous array
of triangle normals.
Triangles may be omitted from processing with the usageFlags parameter,
which should point to an array of TQ3Uns8 flags. If usageFlags is not
nullptr, only triangles whose corresponding entry in this array is 0 will
be processed.
The returning vectors are normalized.
- numTriangles
- The number of triangles to process.
- usageFlags
- The optional usage flags, indicating the triangles to process.
- theIndices
- The triangle indices.
- thePoints
- The triangle points.
- theNormals
- Receives the triangle normals.
Q3Vector2D_Add |
( TQ3Vector2D * _Nonnull ) Q3Vector2D_Add ( const TQ3Vector2D * _Nonnull v1, const TQ3Vector2D * _Nonnull v2, TQ3Vector2D * _Nonnull result );
Add two 2D vectors.
Available in inline form as Q3FastVector2D_Add.
- v1
- Address of first vector to add.
- v2
- Address of second vector to add.
- result
- Address of vector to set (may be the same as v1 and/or v2).
Q3Vector2D_Cross |
( float ) Q3Vector2D_Cross ( const TQ3Vector2D * _Nonnull v1, const TQ3Vector2D * _Nonnull v2 );
Return the length of the cross product of two 2D vectors.
Equivalently, we assume that the 2D vectors are really 3D vectors with
z=0, then return the z coordinate of the cross product (0,0,z).
Available in inline form as Q3FastVector2D_Cross.
- v1
- Address of first vector.
- v2
- Address of second vector.
Q3Vector2D_Dot |
( float ) Q3Vector2D_Dot ( const TQ3Vector2D * _Nonnull v1, const TQ3Vector2D * _Nonnull v2 );
Return the dot product of two 2D vectors.
Available in inline form as Q3FastVector2D_Dot.
- v1
- Address of first vector.
- v2
- Address of second vector.
Q3Vector2D_Length |
( float ) Q3Vector2D_Length ( const TQ3Vector2D * _Nonnull vector2D );
Return length of 2D vector.
Available in inline form as Q3FastVector2D_Length.
- vector2D
- Address of vector to get length of.
Q3Vector2D_LengthSquared |
( float ) Q3Vector2D_LengthSquared ( const TQ3Vector2D * _Nonnull vector2D );
Return squared length of 2D vector.
For many operations, knowing the squared length of a vector is just
as good as knowing the actual length (e.g., when sorting a set of
vectors by length, or comparing a vector to a cut-off length). But
finding the squared length is much faster, since it avoids a costly
square root computation.
Available in inline form as Q3FastVector2D_LengthSquared.
- vector2D
- Address of vector to get length of.
Q3Vector2D_Negate |
( TQ3Vector2D * _Nonnull ) Q3Vector2D_Negate ( const TQ3Vector2D * _Nonnull vector2D, TQ3Vector2D * _Nonnull result );
Scale a 2D vector by a factor of -1.
Available in inline form as Q3FastVector2D_Negate.
- vector2D
- Address of vector to negate.
- result
- Address of vector to set (may be the same as vector2D).
Q3Vector2D_Normalize |
( TQ3Vector2D * _Nonnull ) Q3Vector2D_Normalize ( const TQ3Vector2D * _Nonnull vector2D, TQ3Vector2D * _Nonnull result );
Scale a 2D vector to length 1.
To obtain valid results, the length of vector2D must not be 0.
Available in inline form as Q3FastVector2D_Normalize.
- vector2D
- Address of vector to normalize.
- result
- Address of vector to set (may be the same as vector2D).
Q3Vector2D_Scale |
( TQ3Vector2D * _Nonnull ) Q3Vector2D_Scale ( const TQ3Vector2D * _Nonnull vector2D, float scalar, TQ3Vector2D * _Nonnull result );
Scale a 2D vector by the given factor.
Available in inline form as Q3FastVector2D_Scale.
- vector2D
- Address of vector to scale.
- scalar
- Scaling factor.
- result
- Address of vector to set (may be the same as vector2D).
Q3Vector2D_Set |
( TQ3Vector2D * _Nonnull ) Q3Vector2D_Set ( TQ3Vector2D * _Nonnull vector2D, float x, float y );
Set a 2D vector.
Available in inline form as Q3FastVector2D_Set.
- vector2D
- Address of vector to set (may be nullptr).
- x
- X coordinate to set into vector2D.
- y
- Y coordinate to set into vector2D.
Q3Vector2D_Subtract |
( TQ3Vector2D * _Nonnull ) Q3Vector2D_Subtract ( const TQ3Vector2D * _Nonnull v1, const TQ3Vector2D * _Nonnull v2, TQ3Vector2D * _Nonnull result );
Subtract 2D vector v2 from v1.
Available in inline form as Q3FastVector2D_Subtract.
- v1
- Address of first vector.
- v2
- Address of vector to subtract from v1.
- result
- Address of vector to set (may be the same as v1 and/or v2).
Q3Vector2D_To2DTransformArray |
( TQ3Status ) Q3Vector2D_To2DTransformArray ( const TQ3Vector2D * _Nonnull inVectors2D, const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3Vector2D * _Nonnull outVectors2D, TQ3Uns32 numVectors, TQ3Uns32 inStructSize, TQ3Uns32 outStructSize );
Transform an array of 2D vectors by a 3x3 matrix.
When you have many vectors to transform, this is a more efficient
alternative to calling Q3Vector2D_Transform repeatedly.
- inVectors2D
- Array of 2D vectors to transform.
- matrix3x3
- Transformation matrix.
- outVectors2D
- Array of vectors to receive output (may be the same as inVectors2D).
- numVectors
- How many vectors are in each array.
- inStructSize
- Size of one element of the input array, typically sizeof(TQ3Vector2D).
- outStructSize
- Size of one element of the output array, typically sizeof(TQ3Vector2D).
Q3Vector2D_To3D |
( TQ3Vector3D * _Nonnull ) Q3Vector2D_To3D ( const TQ3Vector2D * _Nonnull vector2D, TQ3Vector3D * _Nonnull result );
Convert 2D vector to 3D, by setting z to 1.
Note: this operation makes no sense mathematically, but is included
for backward-compatibility with QD3D. Perhaps the QD3D
implementation was really intended to convert a 2D vector into a 3D
rational point -- see QDPoint2D_To3D, which does exactly that.
Available in inline form as Q3FastVector2D_To3D.
- vector2D
- Address of 2D vector to convert.
- result
- Address of 3D vector to set.
Q3Vector2D_ToRationalPoint3D |
( TQ3RationalPoint3D * _Nonnull ) Q3Vector2D_ToRationalPoint3D ( const TQ3Vector2D * _Nonnull vector2D, TQ3RationalPoint3D * _Nonnull result );
Convert 2D vector to 3D rational point, setting w to 0.
Available in inline form as Q3FastVector2D_ToRationalPoint3D.
- vector2D
- Address of 2D vector to convert.
- result
- Address of 3D rational point to set.
Q3Vector2D_Transform |
( TQ3Vector2D * _Nonnull ) Q3Vector2D_Transform ( const TQ3Vector2D * _Nonnull vector2D, const TQ3Matrix3x3 * _Nonnull matrix3x3, TQ3Vector2D * _Nonnull result );
Transform a 2D vector by a 3x3 matrix.
Note that the translation and perspective components of the
matrix is ignored (as if it were really a 2x2 matrix).
Contrast with Q3Point2D_Transform, which does the full 3x3
transformation.
- vector2D
- Address of a vector to transform.
- matrix3x3
- Address of a 3x3 transformation matrix.
- result
- Address of vector to set (may be the same as vector2D).
Q3Vector3D_Add |
( TQ3Vector3D * _Nonnull ) Q3Vector3D_Add ( const TQ3Vector3D * _Nonnull v1, const TQ3Vector3D * _Nonnull v2, TQ3Vector3D * _Nonnull result );
Add two 3D vectors.
Available in inline form as Q3FastVector3D_Add.
- v1
- Address of first vector to add.
- v2
- Address of second vector to add.
- result
- Address of vector to set (may be the same as v1 and/or v2).
Q3Vector3D_Cross |
( TQ3Vector3D * _Nonnull ) Q3Vector3D_Cross ( const TQ3Vector3D * _Nonnull v1, const TQ3Vector3D * _Nonnull v2, TQ3Vector3D * _Nonnull result );
Return 3D cross product of two 3D vectors.
Available in inline form as Q3FastVector3D_Cross.
- v1
- Address of first vector.
- v2
- Address of second vector.
- result
- Address of vector to set with the result; may be the same address as v1 and/or v2.
Q3Vector3D_Dot |
( float ) Q3Vector3D_Dot ( const TQ3Vector3D * _Nonnull v1, const TQ3Vector3D * _Nonnull v2 );
Return the dot product of two 3D vectors.
Available in inline form as Q3FastVector3D_Dot.
- v1
- Address of first vector.
- v2
- Address of second vector.
Q3Vector3D_DotArray |
( TQ3Status ) Q3Vector3D_DotArray ( const TQ3Vector3D * _Nonnull inFirstVectors3D, const TQ3Vector3D * _Nonnull inSecondVectors3D, float * _Nonnull outDotProducts, TQ3Boolean * _Nonnull outDotLessThanZeros, TQ3Uns32 numVectors, TQ3Uns32 inStructSize, TQ3Uns32 outDotProductStructSize, TQ3Uns32 outDotLessThanZeroStructSize );
Calculate an array of dot products.
Given two arrays of vectors, an array of dot products is returned along
with an array of TQ3Booleans indicating which dot products are less than
zero.
At least one of dotProducts or dotLessThanZero must be non-nullptr, however
one parameter may be set to nullptr if that information is not required.
- inFirstVectors3D
- First array of 3D vectors to dot.
- inSecondVectors3D
- Second array of 3D vectors to dot.
- outDotProducts
- Array of scalars to receive the dot products.
- outDotLessThanZeros
- Array of booleans to receive the "< 0.0" status of the dot products.
- numVectors
- How many elements are in each array.
- inStructSize
- Size of one element of input arrays, typically sizeof(TQ3Vector3D).
- outDotProductStructSize
- Size of one element of the outDotProducts array, typically sizeof(float).
- outDotLessThanZeroStructSize
- Size of one element of the outDotLessThanZeros array, typically sizeof(TQ3Boolean).
Q3Vector3D_Length |
( float ) Q3Vector3D_Length ( const TQ3Vector3D * _Nonnull vector3D );
Return length of 2D vector.
Available in inline form as Q3FastVector3D_Length.
- vector3D
- Address of vector to get length of.
Q3Vector3D_LengthSquared |
( float ) Q3Vector3D_LengthSquared ( const TQ3Vector3D * _Nonnull vector3D );
Return squared length of 2D vector.
For many operations, knowing the squared length of a vector is just
as good as knowing the actual length (e.g., when sorting a set of
vectors by length, or comparing a vector to a cut-off length). But
finding the squared length is much faster, since it avoids a costly
square root computation.
Available in inline form as Q3FastVector3D_LengthSquared.
- vector3D
- Address of vector to get length of.
Q3Vector3D_Negate |
( TQ3Vector3D * _Nonnull ) Q3Vector3D_Negate ( const TQ3Vector3D * _Nonnull vector3D, TQ3Vector3D * _Nonnull result );
Scale a 3D vector by a factor of -1.
Available in inline form as Q3FastVector3D_Negate.
- vector3D
- Address of vector to negate.
- result
- Address of vector to set (may be the same as vector3D).
Q3Vector3D_Normalize |
( TQ3Vector3D * _Nonnull ) Q3Vector3D_Normalize ( const TQ3Vector3D * _Nonnull vector3D, TQ3Vector3D * _Nonnull result );
Scale a 3D vector to length 1.
To obtain valid results, the length of vector3D must not be 0.
Available in inline form as Q3FastVector3D_Normalize.
- vector3D
- Address of vector to normalize.
- result
- Address of vector to set (may be the same as vector3D).
Q3Vector3D_Scale |
( TQ3Vector3D * _Nonnull ) Q3Vector3D_Scale ( const TQ3Vector3D * _Nonnull vector3D, float scalar, TQ3Vector3D * _Nonnull result );
Scale a 3D vector by the given factor.
Available in inline form as Q3FastVector3D_Scale.
- vector3D
- Address of vector to scale.
- scalar
- Scaling factor.
- result
- Address of vector to set (may be the same as vector3D).
Q3Vector3D_Set |
( TQ3Vector3D * _Nonnull ) Q3Vector3D_Set ( TQ3Vector3D * _Nonnull vector3D, float x, float y, float z );
Set a 3D vector.
Available in inline form as Q3FastVector3D_Set.
- vector3D
- Address of vector to set (may be nullptr).
- x
- X coordinate to set into vector3D.
- y
- Y coordinate to set into vector3D.
- z
- Z coordinate to set into vector3D.
Q3Vector3D_Subtract |
( TQ3Vector3D * _Nonnull ) Q3Vector3D_Subtract ( const TQ3Vector3D * _Nonnull v1, const TQ3Vector3D * _Nonnull v2, TQ3Vector3D * _Nonnull result );
Subtract 3D vector v2 from v1.
Available in inline form as Q3FastVector3D_Subtract.
- v1
- Address of first vector.
- v2
- Address of vector to subtract from v1.
- result
- Address of vector to set (may be the same as v1 and/or v2).
Q3Vector3D_To2D |
( TQ3Vector2D * _Nonnull ) Q3Vector3D_To2D ( const TQ3Vector3D * _Nonnull vector3D, TQ3Vector2D * _Nonnull result );
Convert 3D vector to 2D, dividing by z.
Note: this operation makes no sense mathematically, but is included
for backward-compatibility with QD3D. It's possible that the QD3D
function was really intended to convert a 3D rational point to a
2D vector -- see E3RationalPoint3D_To2D, which does the same thing
for a 2D point.
Available in inline form as Q3FastVector3D_To2D.
- vector3D
- Address of 3D vector to convert.
- result
- Address of 2D vector to set.
Q3Vector3D_To3DTransformArray |
( TQ3Status ) Q3Vector3D_To3DTransformArray ( const TQ3Vector3D * _Nonnull inVectors3D, const TQ3Matrix4x4 * _Nonnull matrix4x4, TQ3Vector3D * _Nonnull outVectors3D, TQ3Uns32 numVectors, TQ3Uns32 inStructSize, TQ3Uns32 outStructSize );
Transform an array of 3D vectors by a 4x4 matrix.
When you have many vectors to transform, this is a more efficient
alternative to calling Q3Vector3D_Transform repeatedly.
- inVectors3D
- Array of 3D vectors to transform.
- matrix4x4
- Transformation matrix.
- outVectors3D
- Array of vectors to receive output (may be the same as inVectors3D).
- numVectors
- How many vectors are in each array.
- inStructSize
- Size of one element of the input array, typically sizeof(TQ3Vector3D).
- outStructSize
- Size of one element of the output array, typically sizeof(TQ3Vector3D).
Q3Vector3D_ToRationalPoint4D |
( TQ3RationalPoint4D * _Nonnull ) Q3Vector3D_ToRationalPoint4D ( const TQ3Vector3D * _Nonnull vector3D, TQ3RationalPoint4D * _Nonnull result );
Convert 3D vector to 4D rational point, setting w to 0.
Available in inline form as Q3FastVector3D_ToRationalPoint4D.
- vector3D
- Address of 3D vector to convert.
- result
- Address of 4D rational point to set.
Q3Vector3D_Transform |
( TQ3Vector3D * _Nonnull ) Q3Vector3D_Transform ( const TQ3Vector3D * _Nonnull vector3D, const TQ3Matrix4x4 * _Nonnull matrix4x4, TQ3Vector3D * _Nonnull result );
Transform a 3D vector by a 4x4 matrix.
Note that the translation and perspective components of the
matrix is ignored (as if it were really a 3x3 matrix).
Contrast with Q3Point3D_Transform, which does the full 4x4
transformation.
- vector3D
- Address of a vector to transform.
- matrix4x4
- Address of a 4x4 transformation matrix.
- result
- Address of vector to set (may be the same as vector3D).
Q3Vector3D_TransformQuaternion |
( TQ3Vector3D * _Nonnull ) Q3Vector3D_TransformQuaternion ( const TQ3Vector3D * _Nonnull vector3D, const TQ3Quaternion * _Nonnull quaternion, TQ3Vector3D * _Nonnull result );
Transform a 3D vector by a quaternion.
Note that for correct results, the quaternion should be normalized.
- vector3D
- Address of a vector to transform.
- quaternion
- Address of a quaternion to transform by.
- result
- Address of a vector to set (may be the same as vector3D).
© 1999-2023 Quesa Developers (Last Updated 1/27/2023)


{% extends "base.html" %}
{% load i18n %}
{% block title %}Home{% endblock %}
{% block body_class %}home{% endblock %}
{% block extra_head %}
{% endblock %}
{% block content %}
Inspired by projects like Pinax and, more recently, Django Canvas, Pickleback.me is a tool to help create and bootstrap a fully working and barebones Django project with all third party packages already integrated in your environment.


List groups are a flexible and powerful component for displaying a series of content. List group items can be modified and extended to support just about any content within. They can also be used as navigation with the right modifier class.
Basic example
The most basic list group is an unordered list with list items and the proper classes. Build upon it with the options that follow, or with your own CSS as needed.
Cras justo odio
Dapibus ac facilisis in
Morbi leo risus
Porta ac consectetur ac
Vestibulum at eros
Active/Disabled items
Add .active to a .list-group-item to indicate the current active selection.
Add .disabled to a .list-group-item to make it appear disabled.
Active list item
Dapibus ac facilisis in
Disabled list item
Porta ac consectetur ac
Vestibulum at eros
Contextual classes
Use contextual classes to style list items with a stateful background and color.
Dapibus ac facilisis in
Dapibus ac facilisis in
Cras sit amet nibh libero
Porta ac consectetur ac
Vestibulum at eros
With badges
Add badges to any list group item to show unread counts, activity and more.


Introduction
When writing a program, you rarely want the exact same outcome every time. Often you will receive some data, inspect the data and decide how to proceed based on that data. For example, in a web application you may like to apply different classes to odd and even table-rows to create visual distinctions. In a game you would want to take different actions if a player hits an obstacle than if they didn’t. We can fork programs into different operational paths using if
statements.
The use of if
statements relies on boolean data types, switching paths depending on whether a condition is true
or false
.
The syntax
In javascript an if
statement looks something like this:
In this example, should the condition
resolve to true
the program would execute firstStatements
, conditionalStatements
, then lastStatements
. However should condition resolve to false
the program would only execute firstStatements
and lastStatements
, skipping over the conditional statements without executing them.
Occasionally, you may like to take an alternative action, should the condition be false. In which case your code will look like this:
In this example, should the condition
evaluate to true the program would still execute firstStatements
, conditionalStatements
, then lastStatements
as before. However, this time when the statement is false it will execute firstStatements
, alternativeStatements
, then lastStatements
. As before, the first & last statements are always executed, as they are outside of the flow.
Sometimes, you may also need to chain multiple conditionals. For this we have else if
used like this:
In this example, the differentStatements
will only be run if the first condition fails, and the second condition passes. The alternativeStatements
will only run if both conditions fail.
some real-world examples
Example 1
In example 1, we fetch a string value from an input field. We then compare the length of the string to a desired maximum display length (20) and if it exceeds that length, we cut it down to it’s first 18 characters, and append an ellipsis.
Example 2
In this example, we add a delivery charge of £10.00 to someones shopping bill, only if the basket contains items totalling less than £100.
Example 3
In this example, a DOM element (el
) has a class of fixed
added or removed depending on the scroll position of the document.
Example 5
In this function, the popular coding challenge FizzBuzz
is solved using if / else statements. An integer Number
is supplied and checked to see if it divides by 3 or 5. If it does Fizz
or Buzz
are returned. If divisible by both FizzBuzz
is returned. If divisible by neither, the Number is converted to a string and returned.