Sun position
Sun position algorithm
|
79 destV->a[0] = srcV1->a[0] + srcV2->a[0];
80 destV->a[1] = srcV1->a[1] + srcV2->a[1];
81 destV->a[2] = srcV1->a[2] + srcV2->a[2];
98 modV1->a[0] += srcV2->a[0];
99 modV1->a[1] += srcV2->a[1];
100 modV1->a[2] += srcV2->a[2];
121 destV->a[0] = srcV1->a[0] - srcV2->a[0];
122 destV->a[1] = srcV1->a[1] - srcV2->a[1];
123 destV->a[2] = srcV1->a[2] - srcV2->a[2];
140 modV1->a[0] -= srcV2->a[0];
141 modV1->a[1] -= srcV2->a[1];
142 modV1->a[2] -= srcV2->a[2];
160 return srcV1->a[0] * srcV2->a[0]
161 + srcV1->a[1] * srcV2->a[1]
162 + srcV1->a[2] * srcV2->a[2];
184 temp.a[0] = (srcV1->a[1] * srcV2->a[2]) - (srcV1->a[2] * srcV2->a[1]);
185 temp.a[1] = (srcV1->a[2] * srcV2->a[0]) - (srcV1->a[0] * srcV2->a[2]);
186 temp.a[2] = (srcV1->a[0] * srcV2->a[1]) - (srcV1->a[1] * srcV2->a[0]);
250 modV1->a[0] *= scale;
251 modV1->a[1] *= scale;
252 modV1->a[2] *= scale;
264 return srcV->a[0] * srcV->a[0]
265 + srcV->a[1] * srcV->a[1]
266 + srcV->a[2] * srcV->a[2];
300 sincos(alpha_rad, &sinA, &cosA);
301 sincos(delta_rad, &sinD, &cosD);
303 destV->a[0] = cosD * cosA;
304 destV->a[1] = cosD * sinA;
326 *alpha_rad = atan2(srcV->a[1], srcV->a[0]);
327 *delta_rad = atan2(srcV->a[2],
328 sqrt(srcV->a[0] * srcV->a[0] + srcV->a[1] * srcV->a[1]));
334 void v3d_polar2Rect(
double alpha_rad,
double delta_rad,
V3D_Vector *R)
347 R->a[0] = cos(delta_rad) * cos(alpha_rad);
348 R->a[1] = cos(delta_rad) * sin(alpha_rad);
349 R->a[2] = sin(delta_rad);
355 bool alphaNonNegative,
369 *alpha_rad = atan2(R->a[1], R->a[0]);
370 if (alphaNonNegative && (*alpha_rad < 0.0)) { *alpha_rad +=
TWOPI; }
371 *delta_rad = atan2(R->a[2], sqrt(R->a[0] * R->a[0] + R->a[1] * R->a[1]));
413 unsigned int i, j, k;
415 REQUIRE((axis == Xaxis) || (axis == Yaxis) || (axis == Zaxis));
419 j = ((axis + 1) % 3);
420 k = ((axis + 2) % 3);
422 destM->a[i][i] = 1.0;
423 destM->a[i][j] = 0.0;
424 destM->a[i][k] = 0.0;
425 destM->a[j][i] = 0.0;
426 destM->a[k][i] = 0.0;
428 sincos(angle_rad, &sinA, &cosA);
430 destM->a[j][j] = cosA;
431 destM->a[j][k] = sinA;
432 destM->a[k][j] = -sinA;
433 destM->a[k][k] = cosA;
464 for (i = 0; i < 3; i++) {
465 temp.a[i] = srcM->a[i][0] * srcV->a[0]
466 + srcM->a[i][1] * srcV->a[1]
467 + srcM->a[i][2] * srcV->a[2];
506 for (i = 0; i < 3; i++) {
507 temp.a[i] = srcM->a[0][i] * srcV->a[0]
508 + srcM->a[1][i] * srcV->a[1]
509 + srcM->a[2][i] * srcV->a[2];
542 for (i = 0; i < 3; i++) {
543 for (j = 0; j < 3; j++) {
544 temp.a[i][j] = srcM1->a[i][0] * srcM2->a[0][j]
545 + srcM1->a[i][1] * srcM2->a[1][j]
546 + srcM1->a[i][2] * srcM2->a[2][j];
double v3d_magVSq(const V3D_Vector *srcV)
Return the square of the magnitude of the specified vector.
V3D_Matrix * v3d_multMxM(V3D_Matrix *destM, const V3D_Matrix *srcM1, const V3D_Matrix *srcM2)
Multiply 3x3 matrix by 3x3 matrix to give a new 3x3 matrix, as per [destM] = [srcM1]*[srcM2].
general.h - definitions of general use to (standard) C programs
V3D_Vector * v3d_polarToRect(V3D_Vector *destV, double alpha_rad, double delta_rad)
Converts polar (curvilinear) coordinates to equivalent rectangular (Cartesian) coordinates.
#define REQUIRE(test_)
Check preconditions.
double v3d_magV(const V3D_Vector *srcV)
Return the magnitude of the specified vector.
V3D_AxisNames
Enumeration to be used by the v3d_createRotationMatrix() function.
void v3d_rectToPolar(double *alpha_rad, double *delta_rad, const V3D_Vector *srcV)
Converts rectangular (Cartesian) coordinates to the equivalent polar (curvilinear) ones.
#define REQUIRE_NOT_NULL(pointer_)
,
V3D_Vector * v3d_addToUV(V3D_Vector *modV1, const V3D_Vector *srcV2)
Modify a unit length rectangular position vector modV1 by adding a correction vector srcV2 to it and ...
V3D_Vector * v3d_multMtransxV(V3D_Vector *destV, const V3D_Matrix *srcM, const V3D_Vector *srcV)
Multiply 3x1 vector by the transpose of the 3x3 matrix to give a new 3x1 vector, as per equation [des...
V3D_Vector * v3d_crossProductV(V3D_Vector *destV, const V3D_Vector *srcV1, const V3D_Vector *srcV2)
Return the cross product of the two vectors: [destV] = [srcV1] x [srcV2].
V3D_Vector * v3d_subFromV(V3D_Vector *modV1, const V3D_Vector *srcV2)
Modify first vector by subtracting a second one: [modV1] -= [srcV2].
V3D_Vector * v3d_addToV(V3D_Vector *modV1, const V3D_Vector *srcV2)
Modify first vector by adding a second one: [modV1] += [srcV2].
instead-of-math.h - header to be included instead of math.h
V3D_Vector * v3d_subtractV(V3D_Vector *destV, const V3D_Vector *srcV1, const V3D_Vector *srcV2)
Vector subtraction: [destV] = [srcV1] - [srcV2].
double v3d_dotProductV(const V3D_Vector *srcV1, const V3D_Vector *srcV2)
Return the dot product of the two vectors: res = [srcV1] · [srcV2] or res = ||srcV1|| * ||srcV2|| * c...
#define DEFINE_THIS_FILE
Leave DEFINE_THIS_FILE undefined.
V3D_Vector * v3d_addV(V3D_Vector *destV, const V3D_Vector *srcV1, const V3D_Vector *srcV2)
Add two vectors: [destV] = [srcV1] + [srcV2].
V3D_Matrix * v3d_createRotationMatrix(V3D_Matrix *destM, V3D_AxisNames axis, double angle_rad)
Creates a matrix to rotate a coordinate system about an axis.
vectors3d.h - Three dimensional geometry, vectors and matrices
V3D_Vector * v3d_addToUVfast(V3D_Vector *modV1, const V3D_Vector *srcV2)
Modify a unit length rectangular position vector modV1 by adding a small correction vector srcV2 to i...
static void sincos(double angle_rad, double *sinA, double *cosA)
Calculates sine and cosine of an angle.
V3D_Vector * v3d_multMxV(V3D_Vector *destV, const V3D_Matrix *srcM, const V3D_Vector *srcV)
Multiply 3x3 matrix by 3x1 vector to give a new 3x1 vector, as per equation [destV] = [srcM] * [srcV]...