Skip to content

Commit

Permalink
adding a lot to the Temperature and Heat classes and fixing up some o…
Browse files Browse the repository at this point in the history
…f the values under latent heat of vapor and fusion that I noticed were not correct.
  • Loading branch information
RyanZurrin committed Aug 22, 2022
1 parent a3acebf commit 9550a82
Show file tree
Hide file tree
Showing 119 changed files with 830 additions and 629 deletions.
36 changes: 18 additions & 18 deletions BinarySpacePartition.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ namespace rez {
rez::Line2dStd line;

if (!_prev_line) {
p1.assign(X, (_points_list[0][X] + _points_list[1][X]) / 2);
p1.assign(Y, (_points_list[0][Y] + _points_list[1][Y]) / 2);
p2.assign(X, (_points_list[size - 1][X] + _points_list[size - 2][X]) / 2);
p2.assign(Y, (_points_list[size - 1][Y] + _points_list[size - 2][Y]) / 2);
p1.assign(X_, (_points_list[0][X_] + _points_list[1][X_]) / 2);
p1.assign(Y_, (_points_list[0][Y_] + _points_list[1][Y_]) / 2);
p2.assign(X_, (_points_list[size - 1][X_] + _points_list[size - 2][X_]) / 2);
p2.assign(Y_, (_points_list[size - 1][Y_] + _points_list[size - 2][Y_]) / 2);
line = rez::Line2dStd(p1, p2, true);
}
else if (false) {
Expand All @@ -95,9 +95,9 @@ namespace rez {

for (const auto& point : _points_list)
{
nxy += point[X] * point[Y];
x_sum += point[X];
y_sum += point[Y];
nxy += point[X_] * point[Y_];
x_sum += point[X_];
y_sum += point[Y_];
n_x_sqr_sum += x_sum * x_sum;
}

Expand All @@ -110,28 +110,28 @@ namespace rez {
srand((unsigned)time(0));
auto s = rand() % 50;
s /= 25.0;
p2.assign(X, -slope * s);
p2.assign(Y, 1 + s);
p2.assign(X_, -slope * s);
p2.assign(Y_, 1 + s);

line = rez::Line2dStd(p1, p2, false);
}
else {
float x_sum = 0.0, y_sum = 0.0;
for (const auto& point : _points_list)
{
x_sum += point[X];
y_sum += point[Y];
x_sum += point[X_];
y_sum += point[Y_];
}
p1.assign(X, x_sum / size);
p1.assign(Y, y_sum / size);
p1.assign(X_, x_sum / size);
p1.assign(Y_, y_sum / size);

p2.assign(X, -_prev_line->getDir()[Y] + 0.2);
p2.assign(Y, _prev_line->getDir()[X] + 0.2);
p2.assign(X_, -_prev_line->getDir()[Y_] + 0.2);
p2.assign(Y_, _prev_line->getDir()[X_] + 0.2);

line = rez::Line2dStd(p1, p2, false);
}

Vector2f normal(-line.getDir()[Y], line.getDir()[X]);
Vector2f normal(-line.getDir()[Y_], line.getDir()[X_]);
auto d = dotProduct(normal, p2);
line.setD(d);
return line;
Expand Down Expand Up @@ -315,8 +315,8 @@ namespace rez {
int space = 0;
while (space < depth)
std::cout << " ";
std::cout << "< (" << _node->segment.p1[X] << "," << _node->segment.p1[Y] << ") - ("
<< _node->segment.p2[X] << "," << _node->segment.p2[Y] << ")\n";
std::cout << "< (" << _node->segment.p1[X_] << "," << _node->segment.p1[Y_] << ") - ("
<< _node->segment.p2[X_] << "," << _node->segment.p2[Y_] << ")\n";

printNode(_node->neg, depth + 1);
}
Expand Down
4 changes: 2 additions & 2 deletions Boundries.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace rez {
float y_max;

bool isInside(Point2d& point) {
if (x_min <= point[X] && point[X] <= x_max
&& y_min <= point[Y] && point[Y] <= y_max)
if (x_min <= point[X_] && point[X_] <= x_max
&& y_min <= point[Y_] && point[Y_] <= y_max)
return true;
return false;
}
Expand Down
12 changes: 9 additions & 3 deletions Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,17 @@ namespace constants {
*/
constexpr auto BOLTZMANN = 1.38064852e-23;


/**
* Gas constant, R = 8.314 J/mol K
* @brief Global constant _R_ is the universal gas constant struct which has _R_
* in different units for use in different kinds of problems all represented
* as unit/mol * K
*/
constexpr auto R = 8.314;
const struct UniversalGasConstant
{
const long double joules = 8.314; //8.31 J/mol * K
const long double cal = 1.99; // 1.99 cal/mol * k
const long double L_atm = .0821; // .0821 L * atm/mol * K
}R;

constexpr auto DEGREE = 180.0/PI;
constexpr auto RADIAN = PI/180.0;
Expand Down
26 changes: 13 additions & 13 deletions Convexhull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ void rez::convexhull2DGiftwrapping(std::vector<Point2d>& _points, std::vector<Po
Point2d bottom_point = _points[0];

for (Point2d& point : _points) {
if ((point[Y] < bottom_point[Y])
|| (point[Y] == bottom_point[Y]) && (point[X] < bottom_point[X])) {
if ((point[Y_] < bottom_point[Y_])
|| (point[Y_] == bottom_point[Y_]) && (point[X_] < bottom_point[X_])) {
bottom_point = point;
}
}
Expand Down Expand Up @@ -137,8 +137,8 @@ void rez::convexhull2DIncremental(std::vector<Point3d>& _points, std::vector<Poi
{
//Sort the points left to right order
std::sort(_points.begin(), _points.end(), [](const Point3d& a, const Point3d& b) {
if ((a[X] < b[X])
|| (a[X] == b[X]) && (a[Y] < b[Y]))
if ((a[X_] < b[X_])
|| (a[X_] == b[X_]) && (a[Y_] < b[Y_]))
{
return true;
}
Expand Down Expand Up @@ -234,8 +234,8 @@ void rez::convexhull2DDivideAndConquer(std::vector<Point3d>& _points, Polygon& _
{
//Sort the points left to right order
std::sort(_points.begin(), _points.end(), [](const Point3d& a, const Point3d& b) {
if ((a[X] < b[X])
|| (a[X] == b[X]) && (a[Y] < b[Y]))
if ((a[X_] < b[X_])
|| (a[X_] == b[X_]) && (a[Y_] < b[Y_]))
{
return true;
}
Expand Down Expand Up @@ -297,14 +297,14 @@ void rez::convexhull2DQuickhull(std::vector<Point3d>& _points, std::vector<Point

for (Point3d& point : _points)
{
if ((point[X] < left_top[X])
|| (point[X] == left_top[X]) && (point[Y] > left_top[X]))
if ((point[X_] < left_top[X_])
|| (point[X_] == left_top[X_]) && (point[Y_] > left_top[X_]))
{
left_top = point;
}

if ((point[X] > right_bot[X])
|| (point[X] == right_bot[X]) && (point[Y] < right_bot[X]))
if ((point[X_] > right_bot[X_])
|| (point[X_] == right_bot[X_]) && (point[Y_] < right_bot[X_]))
{
right_bot = point;
}
Expand Down Expand Up @@ -439,9 +439,9 @@ void rez::convexhull3D(std::vector<Point3d>& _points, std::vector<Face*>& faces)
}

// We need to find a point inside the
float x_mean = (_points[i][X] + _points[i + 1][X] + _points[i + 2][X] + _points[i + 3][X]) / 4;
float y_mean = (_points[i][Y] + _points[i + 1][Y] + _points[i + 2][Y] + _points[i + 3][Y]) / 4;
float z_mean = (_points[i][Z] + _points[i + 1][Z] + _points[i + 2][Z] + _points[i + 3][Z]) / 4;
float x_mean = (_points[i][X_] + _points[i + 1][X_] + _points[i + 2][X_] + _points[i + 3][X_]) / 4;
float y_mean = (_points[i][Y_] + _points[i + 1][Y_] + _points[i + 2][Y_] + _points[i + 3][Y_]) / 4;
float z_mean = (_points[i][Z_] + _points[i + 1][Z_] + _points[i + 2][Z_] + _points[i + 3][Z_]) / 4;
float x_p = x_mean;
float y_p = y_mean;
float z_p = z_mean;
Expand Down
10 changes: 5 additions & 5 deletions Distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ float rez::distance(Line2d& line, Point2d& C)

float rez::distance(Point3d& p1, Point3d& p2)
{
float dx = p1[X] - p2[X];
float dy = p1[Y] - p2[Y];
float dz = p1[Z] - p2[Z];
float dx = p1[X_] - p2[X_];
float dy = p1[Y_] - p2[Y_];
float dz = p1[Z_] - p2[Z_];

float distance = sqrt(pow(dx, 2) + pow(dy, 2) + pow(dz, 2));
return distance;
}

float rez::distance(Point2d& p1, Point2d& p2)
{
float dx = p1[X] - p2[X];
float dy = p1[Y] - p2[Y];
float dx = p1[X_] - p2[X_];
float dy = p1[Y_] - p2[Y_];
float distance = sqrt(pow(dx, 2) + pow(dy, 2));
return distance;
}
Expand Down
2 changes: 1 addition & 1 deletion Elasticity.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Elasticity

/**
* structure: Elastic_Moduli vector
* components: <young's modulus, Shear modulus, Bulk modulus> Y, S, B
* components: <young's modulus, Shear modulus, Bulk modulus> Y_, S, B
* purpose: store data on elastic moduli for using in physics calculations
* returns: specified component value
*/
Expand Down
2 changes: 1 addition & 1 deletion ElectricCurrent.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
/// setWOOD method you can use to adjust its value of the power. Its not checked so if you
/// put in a invalid number its on you, your calculation will be wrong.
/// </summary>
long double WOOD = pow(10, 9); // 10^X conductor, OHm*m
long double WOOD = pow(10, 9); // 10^X_ conductor, OHm*m
/// <summary>
/// Sets the GLASS variable.
/// </summary>
Expand Down
14 changes: 7 additions & 7 deletions ElectroMagneticInduction.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,19 +559,19 @@ class ElectroMagneticInduction :

/// <summary>
/// Calculates the peeks the current in an AC circuit using the peek voltage
/// of Vo and its impedance of Z.
/// of Vo and its impedance of Z_.
/// </summary>
/// <param name="Vo">The peek voltage in circuit.</param>
/// <param name="Z">The impedance.</param>
/// <param name="Z_">The impedance.</param>
/// <returns>The peek current -> Io = peek Amps</returns>
static ld peekCurrent_AC(const ld Vo, const ld Z);

/// <summary>
/// Calculates the RMS(root mean square) or average current in an AC circuit
/// using the rms Voltage and the circuits impedance of Z.
/// using the rms Voltage and the circuits impedance of Z_.
/// </summary>
/// <param name="Vrms">The rms Voltage, average voltage.</param>
/// <param name="Z">The impedance in circuit.</param>
/// <param name="Z_">The impedance in circuit.</param>
/// <returns>the average or rms current Irms -> (A)</returns>
static ld rmsCurrent_AC(const ld Vrms, const ld Z);

Expand Down Expand Up @@ -628,10 +628,10 @@ class ElectroMagneticInduction :
static ld resonantFrequency(const ld L, const ld C);

/// <summary>
/// Calculates the power factor. cos(phi) = R/Z.
/// Calculates the power factor. cos(phi) = R/Z_.
/// </summary>
/// <param name="R">The resistance.</param>
/// <param name="Z">The impedance.</param>
/// <param name="Z_">The impedance.</param>
/// <returns>power factor(unit-less)</returns>
static ld powerFactor(const ld R, const ld Z);

Expand All @@ -646,7 +646,7 @@ class ElectroMagneticInduction :
/// Phases the angle.
/// </summary>
/// <param name="R">The resistance.</param>
/// <param name="Z">The impedance.</param>
/// <param name="Z_">The impedance.</param>
/// <returns>phase angle</returns>
static ld phaseAngle(const ld R, const ld Z);

Expand Down
2 changes: 1 addition & 1 deletion ElectroMagneticWaves.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ElectromagneticWaves :
static ld distanceFromRadarStation(const ld t);

/// <summary>
/// Determine the amount of time it takes for X-rays to travel
/// Determine the amount of time it takes for X_-rays to travel
/// a distance of d(m).
/// </summary>
/// <param name="d">The distance.</param>
Expand Down
12 changes: 6 additions & 6 deletions FluidDynamics.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,19 +451,19 @@ class FluidDynamics
}

/**
* @brief X has a nuclei density around rhoX while Y's density is rhoY.
* Roughly what fraction of Y's volume is not empty space?
* @param rhoX nuclei density of X
* @param rhoY nuclei density of Y
* @brief X_ has a nuclei density around rhoX while Y_'s density is rhoY.
* Roughly what fraction of Y_'s volume is not empty space?
* @param rhoX nuclei density of X_
* @param rhoY nuclei density of Y_
* @param print print results to console
* @return fraction of Y's volume that is not empty space
* @return fraction of Y_'s volume that is not empty space
*/
static ld fractionOfYVolumeNotEmptySpace(const ld rhoX,
const ld rhoY,
bool print = false) {
auto fraction = (rhoY / rhoX);
if (print) {
std::cout << "fraction of Y's volume that is not empty space: "
std::cout << "fraction of Y_'s volume that is not empty space: "
<< fraction << std::endl;
}
return fraction;
Expand Down
36 changes: 18 additions & 18 deletions GeoUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// return LEFT;
// if (area < 0.0)
// return RIGHT;
// if ((ab[X] * ac[X] < 0.0) || (ab[Y] * ac[Y] < 0.0))
// if ((ab[X_] * ac[X_] < 0.0) || (ab[Y_] * ac[Y_] < 0.0))
// return BEHIND;
// if (ab.magnitude() < ac.magnitude())
// return BEYOND;
Expand Down Expand Up @@ -61,10 +61,10 @@ int rez::orientation3d(const Point3d& a, const Point3d& b, const Point3d& c)

double p1x, p1y, p2x, p2y;

p1x = p1[X];
p1y = p1[Y];
p2x = p2[X];
p2y = p2[Y];
p1x = p1[X_];
p1y = p1[Y_];
p2x = p2[X_];
p2y = p2[Y_];

if (area > 0.0)
return LEFT;
Expand Down Expand Up @@ -105,7 +105,7 @@ int rez::orientation2d(const Point2d& a, const Point2d& b, const Point2d& c)
return LEFT;
if (area < 0.0)
return RIGHT;
if ((ab[X] * ac[X] < 0.0) || (ab[Y] * ac[Y] < 0.0))
if ((ab[X_] * ac[X_] < 0.0) || (ab[Y_] * ac[Y_] < 0.0))
return BEHIND;
if (ab.magnitude() < ac.magnitude())
return BEYOND;
Expand Down Expand Up @@ -136,7 +136,7 @@ bool rez::left(const Point2d& a, const Point2d& b, const Point2d& c)
bool rez::left(const Line2dStd& l, const Point2d& p)
{
auto line_dir = l.getDir();
Vector2f line_normal(-line_dir[Y], line_dir[X]);
Vector2f line_normal(-line_dir[Y_], line_dir[X_]);
auto value = dotProduct(line_normal, p);
return (dotProduct(line_normal, p) - l.getD()) < 0 ? false : true;
}
Expand Down Expand Up @@ -218,8 +218,8 @@ bool rez::isDiagonal(const Vertex2dSimple* v1, const Vertex2dSimple* v2, Polygon
float rez::polarAngle(const Point2d& _other, const Point2d& _ref)
{
// Consider the given points as 2D ones which are in XY plane
float _x = _other[X] - _ref[X];
float _y = _other[Y] - _ref[Y];
float _x = _other[X_] - _ref[X_];
float _y = _other[Y_] - _ref[Y_];

if ((isEqualD(_x, 0.0)) && (isEqualD(_y, 0.0)))
return -1.0;
Expand All @@ -238,12 +238,12 @@ float rez::polarAngle(const Point2d& _other, const Point2d& _ref)

double rez::areaTriangle2d(const Point3d& a, const Point3d& b, const Point3d& c)
{
return 0.5 * ((b[X] - a[X]) * (c[Y] - a[Y]) - (c[X] - a[X]) * (b[Y] - a[Y]));
return 0.5 * ((b[X_] - a[X_]) * (c[Y_] - a[Y_]) - (c[X_] - a[X_]) * (b[Y_] - a[Y_]));
}

double rez::areaTriangle2d(const Point2d& a, const Point2d& b, const Point2d& c)
{
return 0.5 * ((b[X] - a[X]) * (c[Y] - a[Y]) - (c[X] - a[X]) * (b[Y] - a[Y]));
return 0.5 * ((b[X_] - a[X_]) * (c[Y_] - a[Y_]) - (c[X_] - a[X_]) * (b[Y_] - a[Y_]));
}

double rez::areaTriangle3d(const Point3d& a, const Point3d& b, const Point3d& c)
Expand All @@ -253,9 +253,9 @@ double rez::areaTriangle3d(const Point3d& a, const Point3d& b, const Point3d& c)
Vector3f AB = b - a;
Vector3f AC = c - a;

x_ = AB[Y] * AC[Z] - AB[Z] * AC[Y];
y_ = AB[X] * AC[Z] - AB[Z] * AC[X];
z_ = AB[X] * AC[Y] - AB[Y] * AC[X];
x_ = AB[Y_] * AC[Z_] - AB[Z_] * AC[Y_];
y_ = AB[X_] * AC[Z_] - AB[Z_] * AC[X_];
z_ = AB[X_] * AC[Y_] - AB[Y_] * AC[X_];

float sum_of_powers = pow(x_, 2.0) + pow(y_, 2.0) + pow(z_, 2.0);
float root = sqrtf(sum_of_powers);
Expand Down Expand Up @@ -347,9 +347,9 @@ bool rez::collinear(const Point3d& a, const Point3d& b, const Point3d& c)

bool rez::collinear(const Vector3f& a, const Vector3f& b)
{
auto v1 = a[X] * b[Y] - a[Y] * b[X];
auto v2 = a[Y] * b[Z] - a[Z] * b[Y];
auto v3 = a[X] * b[Z] - a[Z] * b[X];
auto v1 = a[X_] * b[Y_] - a[Y_] * b[X_];
auto v2 = a[Y_] * b[Z_] - a[Z_] * b[Y_];
auto v3 = a[X_] * b[Z_] - a[Z_] * b[X_];

return isEqualD(v1, ZERO) && isEqualD(v2, ZERO) && isEqualD(v3, ZERO);
}
Expand All @@ -370,5 +370,5 @@ bool rez::coplaner(const Vector3f& _v1, const Vector3f& _v2, const Vector3f& _v3

bool rez::segmentIsLeft(const Segment2d& base, const Segment2d& compare, const Point2d& _point)
{
return base.get_x(_point[Y]) < compare.get_x(_point[Y]);
return base.get_x(_point[Y_]) < compare.get_x(_point[Y_]);
}
Loading

0 comments on commit 9550a82

Please sign in to comment.