#import "ccTypes.h"
#import "CC3Math.h"
#import "CC3Logging.h"
#define cc3v | ( | X, | |
Y, | |||
Z | |||
) | CC3VectorMake((X),(Y),(Z)) |
Convenience alias macro to create CC3Vectors with less keystrokes.
typedef GLfloat CC3Angle |
An angle such as a heading or inclination.
Can be measured in degrees or radians and may be positive or negative.
CC3AngularVector CC3AngularVectorDifference | ( | CC3AngularVector | minuend, |
CC3AngularVector | subtrahend | ||
) |
Returns the difference between two CC3AngularVectors, by subtracting the corresponding heading, inclination & radial components.
Note that this is NOT true vector arithmetic, which would yield a completely different angular and radial results.
CC3AngularVector CC3AngularVectorFromVector | ( | CC3Vector | v ) |
Returns an CC3AngularVector providing the heading, inclination & radius of the specified CC3Vector.
Heading is measured in degrees, in the X-Z plane, clockwise from the negative Z-axis. Inclination is measured in degrees, with up being in the positive-Y direction.
CC3AngularVector CC3AngularVectorMake | ( | GLfloat | heading, |
GLfloat | inclination, | ||
GLfloat | radius | ||
) |
Returns an CC3AngularVector structure constructed from the vector components.
Returns the distance from the point represented by the vector to the specified normalized plane.
CC3Plane CC3PlaneMake | ( | GLfloat | a, |
GLfloat | b, | ||
GLfloat | c, | ||
GLfloat | d | ||
) |
Returns a CC3Plane structure constructed from the specified coefficients.
Returns a normalized copy of the specified CC3Plane so that the length of its normal (a, b, c) is 1.0.
GLfloat CC3Vector4Dot | ( | CC3Vector4 | v1, |
CC3Vector4 | v2 | ||
) |
Returns the dot-product of the two given vectors (v1 .
v2).
CC3Vector4 CC3Vector4FromCC3Vector | ( | CC3Vector | v, |
GLfloat | w | ||
) |
Returns a CC3Vector4 structure constructed from a 3D vector and a w component.
CC3Vector4 CC3Vector4Homogenize | ( | CC3Vector4 | v ) |
If the specified homogeneous vector represents a location (w is not zero), returns a homoginized copy of the vector, by dividing each component by the w-component (including the w-component itself, leaving it with a value of one).
If the specified vector is a direction (w is zero), the vector is returned unchanged.
GLfloat CC3Vector4Length | ( | CC3Vector4 | v ) |
Returns the scalar length of the specified vector from the origin, including the w-component This is calculated as sqrt(x*x + y*y + z*z + w*w) and will always be positive.
CC3Vector4 CC3Vector4Make | ( | GLfloat | x, |
GLfloat | y, | ||
GLfloat | z, | ||
GLfloat | w | ||
) |
Returns a CC3Vector4 structure constructed from the vector components.
CC3Vector4 CC3Vector4Negate | ( | CC3Vector4 | v ) |
Returns a vector that is the negative of the specified vector in all directions.
CC3Vector4 CC3Vector4Normalize | ( | CC3Vector4 | v ) |
Returns a normalized copy of the specified vector so that its length is 1.0.
The w-component is also normalized.
BOOL CC3Vector4sAreEqual | ( | CC3Vector4 | v1, |
CC3Vector4 | v2 | ||
) |
Returns whether the two vectors are equal by comparing their respective components.
CC3Vector4 CC3Vector4ScaleUniform | ( | CC3Vector4 | v, |
GLfloat | scale | ||
) |
Returns the result of scaling the original vector by the corresponding scale factor uniformly along all axes.
CC3Vector4 CC3Vector4Slerp | ( | CC3Vector4 | v1, |
CC3Vector4 | v2, | ||
GLfloat | blendFactor | ||
) |
Returns a spherical linear interpolation between the two vectors, based on the blendFactor, which should be between zero and one.
CC3Vector4 CC3Vector4Translate | ( | CC3Vector4 | v, |
CC3Vector4 | translation | ||
) |
Returns the result of translating the original vector by the corresponding translation amounts in each direction.
This corresponds to an addition of one vector to the other.
Returns the result of adding the two specified vectors, by adding the corresponding components of both vectors.
This can also be thought of as a translation of the first vector by the second.
Returns the cross-product of the two given vectors (v1 x v2).
Returns the difference between two vectors, by subtracting the subtrahend from the minuend, which is accomplished by subtracting each of the corresponding x,y,z components.
Returns the positive scalar distance between the ends of the two specified vectors.
Returns the dot-product of the two given vectors (v1 .
v2).
CC3Vector CC3VectorFromAngularVector | ( | CC3AngularVector | av ) |
Returns a CC3Vector from the specified CC3AngularVector.
Heading is measured in degrees, in the X-Z plane, clockwise from the negative Z-axis. Inclination is measured in degrees, with up being in the positive-Y direction.
CC3Vector CC3VectorFromCC3Vector4 | ( | CC3Vector4 | v ) |
Returns a CC3Vector structure constructed from a CC3Vector4.
The CC3Vector4 is first homogenized (via CC3Vector4Homogenize), before copying the resulting x, y & z coordinates into the CC3Vector.
Returns a CC3Vector that is the inverse of the specified vector in all directions, such that scaling the original by the inverse using CC3VectorScale will result in a vector of unit dimension in each direction (1.0, 1.0, 1.0).
The result of this function is effectively calculated by dividing each component of the original vector into 1.0 (1.0/x, 1.0/y, 1.0/z). It is the responsibility of the caller to ensure that none of the components of the original is zero.
GLfloat CC3VectorLength | ( | CC3Vector | v ) |
Returns the scalar length of the specified CC3Vector from the origin.
This is calculated as sqrt(x*x + y*y + z*z) and will always be positive.
Returns a linear interpolation between two vectors, based on the blendFactor.
which should be between zero and one. The returned value is calculated as v1 + (blendFactor * (v2 - v1)).
CC3Vector CC3VectorMake | ( | GLfloat | x, |
GLfloat | y, | ||
GLfloat | z | ||
) |
Returns a CC3Vector structure constructed from the vector components.
Returns a vector whose components comprise the maximum value of each of the respective components of the two specfied vectors.
In general, do not expect this method to return one of the specified vectors, but a new vector, each of the components of which is the maximum value for that component between the two vectors.
Returns a vector whose components comprise the minimum value of each of the respective components of the two specfied vectors.
In general, do not expect this method to return one of the specified vectors, but a new vector, each of the components of which is the minimum value for that component between the two vectors.
Returns a vector that is the negative of the specified vector in all directions.
For vectors that represent directions, the returned vector points in the direction opposite to the original.
Returns a normalized copy of the specified CC3Vector so that its length is 1.0.
Returns the difference between two rotation vectors, in terms of the minimal degrees, along each axis, required to travel between the two roations, given that rotations are cyclical with a period of 360 degrees.
The result may be positive or negative, but will always be between (+/-180 degrees).
For example, the difference between 350 and 10 will yield -20 (ie- the smallest change from 10 degrees to 350 degrees is -20 degrees) rather than +340 (from simple subtraction). Similarly, the difference between 10 and 350 will yield +20 (ie- the smallest change from 350 degrees to 10 degrees is +20 degrees) rather than -340 (from simple subtraction).
Returns whether the two vectors are equal by comparing their respective components.
Returns the result of scaling the original vector by the corresponding scale vector.
Scaling can be different for each axis. This has the effect of multiplying each component of the vector by the corresponding component in the scale vector.
Returns the result of scaling the original vector by the corresponding scale factor uniformly along all axes.
BOOL CC3ViewportContainsPoint | ( | CC3Viewport | vp, |
CGPoint | point | ||
) |
Returns whether the specified point lies within the specified viewport.
A point is considered inside the viewport if its coordinates lie inside the viewport or on the minimum X or minimum Y edge.
CC3Viewport CC3ViewportMake | ( | GLint | x, |
GLint | y, | ||
GLint | w, | ||
GLint | h | ||
) |
Returns a CC3Viewport structure constructed from the specified components.
BOOL CC3ViewportsAreEqual | ( | CC3Viewport | vp1, |
CC3Viewport | vp2 | ||
) |
Returns whether the two viewports are equal by comparing their respective components.
BOOL CCC4FAreEqual | ( | ccColor4F | c1, |
ccColor4F | c2 | ||
) |
Returns whether the two colors are equal by comparing their respective components.
ccColor4F CCC4FBlend | ( | ccColor4F | baseColor, |
ccColor4F | blendColor, | ||
GLfloat | blendWeight | ||
) |
Returns an ccColor4F structure whose values are a weighted average of the specified base color and the blend color.
The parameter blendWeight should be between zero and one. A value of zero will leave the base color unchanged. A value of one will result in the blend being the same as the blend color.
ccColor4F CCC4FMake | ( | GLfloat | red, |
GLfloat | green, | ||
GLfloat | blue, | ||
GLfloat | alpha | ||
) |
Returns an ccColor4F structure constructed from the specified components.
ccColor4F CCC4FTranslate | ( | ccColor4F | rgba, |
ccColor4F | translation | ||
) |
Returns an ccColor4F structure whose values are those of the specified original color, where each color component has been translated by the corresponding color component in the specified translation.
Each of the resulting color components is clamped to be between 0.0 and 1.0.
ccColor4F CCC4FUniformTranslate | ( | ccColor4F | rgba, |
GLfloat | offset | ||
) |
Returns an ccColor4F structure whose values are those of the specified original color, where each color component has been translated by the specified offset.
Each of the resulting color components is clamped to be between 0.0 and 1.0.
GLubyte CCColorByteFromFloat | ( | GLfloat | colorValue ) |
Returns a GLubyte between 0 and 255 converted from the specified GLfloat value between 0 and 1.
GLfloat CCColorFloatFromByte | ( | GLubyte | colorValue ) |
Returns a GLfloat between 0 and 1 converted from the specified GLubyte value between 0 and 255.
CGRect CGRectFromCC3Viewport | ( | CC3Viewport | vp ) |
Returns the dimensions of the specified viewport as a rectangle.
NSString* NSStringFromCC3AngularVector | ( | CC3AngularVector | av ) |
Returns a string description of the specified CC3AngularVector struct in the form "(heading, inclination, radius)".
NSString* NSStringFromCC3Plane | ( | CC3Plane | p ) |
Returns a string description of the specified CC3Plane struct in the form "(a, b, c, d)".
NSString* NSStringFromCC3Vector | ( | CC3Vector | v ) |
Returns a string description of the specified CC3Vector struct in the form "(x, y, z)".
NSString* NSStringFromCC3Vector4 | ( | CC3Vector4 | v ) |
Returns a string description of the specified CC3Vector4 struct in the form "(x, y, z, w)".
NSString* NSStringFromCC3Viewport | ( | CC3Viewport | vp ) |
Returns a string description of the specified CC3Viewport struct in the form "(x, y, w, h)".
NSString* NSStringFromCCC4F | ( | ccColor4F | rgba ) |
Returns a string description of the specified ccColor4F in the form "(r, g, b, a)".
ccColor4F RandomCCC4FBetween | ( | ccColor4F | min, |
ccColor4F | max | ||
) |
Returns a random ccColor4F where each component value between the specified min inclusive and the specified max exclusive.
This can be useful when creating particle systems.
const CC3Vector4 kCC3Vector4QuaternionIdentity = { 0.0, 0.0, 0.0, 1.0 } [static] |
A CC3Vector4 that represents the identity quaternion.
const CC3Vector kCC3VectorUnitCube = { 1.0, 1.0, 1.0 } [static] |
A CC3Vector with each component equal to one, representing the diagonal of a unit cube.
const GLfloat kCC3VectorUnitCubeLength = M_SQRT3 [static] |
The diagonal length of a unit cube.
const CC3Vector kCC3VectorUnitXNegative = {-1.0, 0.0, 0.0 } [static] |
Unit vector pointing in the same direction as the negative X-axis.
const CC3Vector kCC3VectorUnitXPositive = { 1.0, 0.0, 0.0 } [static] |
Unit vector pointing in the same direction as the positive X-axis.
const CC3Vector kCC3VectorUnitYNegative = { 0.0, -1.0, 0.0 } [static] |
Unit vector pointing in the same direction as the negative Y-axis.
const CC3Vector kCC3VectorUnitYPositive = { 0.0, 1.0, 0.0 } [static] |
Unit vector pointing in the same direction as the positive Y-axis.
const CC3Vector kCC3VectorUnitZNegative = { 0.0, 0.0, -1.0 } [static] |
Unit vector pointing in the same direction as the negative Z-axis.
const CC3Vector kCC3VectorUnitZPositive = { 0.0, 0.0, 1.0 } [static] |
Unit vector pointing in the same direction as the positive Z-axis.
const CC3Vector kCC3VectorZero = { 0.0, 0.0, 0.0 } [static] |
A CC3Vector of zero length at the origin.
const ccColor4F kCCC4FBlack = {0.0, 0.0, 0.0, 1.0} [static] |
Opaque Black.
const ccColor4F kCCC4FBlackTransparent = {0.0, 0.0, 0.0, 0.0} [static] |
Transparent Black.
const ccColor4F kCCC4FBlue = {0.0, 0.0, 1.0, 1.0} [static] |
Opaque Blue.
const ccColor4F kCCC4FGreen = {0.0, 1.0, 0.0, 1.0} [static] |
Opaque Green.
const ccColor4F kCCC4FRed = {1.0, 0.0, 0.0, 1.0} [static] |
Opaque Red.
const ccColor4F kCCC4FWhite = {1.0, 1.0, 1.0, 1.0} [static] |
Opaque White.