I am using WKHTMLTOPDF in ColdFusion 18 and am trying to have the page size be "Envelope DL". I found the global setting size.PageSize so in the code below I added pagesize = "Envelope DL" but this did not change it. Does anyone have any other ideas or could tell me what I am missing?
Any help would be greatly appreciated!
<CF_WKHTMLTOPDF
PageURL = "http://www.com/temppdf/test.htm"
filename = "D://temppdf/test.pdf"
orientation = "portrait"
DisableSmartShrinking="yes"
margintop = "0.25"
marginleft = "0.25"
marginright = "0.25"
marginbottom = "0.25"
TimeOut = "180"
AddFooterPageNum="yes">
<cfheader name="content-disposition" value="inline; filename=""CS_#Dateformat(NOW(),'MMDDYYYY')#.pdf""">
<cfcontent type="application/pdf" file="D://temppdf/test.pdf" deletefile="Yes">
I wrote the ColdFusion WKHTMLTOPDF custom tag. If you look at the source code, the notes indicate where to look for the "pagesize" parameter.
Here are the allowable paper sizes. (I've used "Comm10E" for my envelopes):
http://doc.qt.io/qt-4.8/qprinter.html#PaperSize-enum
QPrinter::A0 5 841 x 1189 mm
QPrinter::A1 6 594 x 841 mm
QPrinter::A2 7 420 x 594 mm
QPrinter::A3 8 297 x 420 mm
QPrinter::A4 0 210 x 297 mm, 8.26 x 11.69 inches
QPrinter::A5 9 148 x 210 mm
QPrinter::A6 10 105 x 148 mm
QPrinter::A7 11 74 x 105 mm
QPrinter::A8 12 52 x 74 mm
QPrinter::A9 13 37 x 52 mm
QPrinter::B0 14 1000 x 1414 mm
QPrinter::B1 15 707 x 1000 mm
QPrinter::B2 17 500 x 707 mm
QPrinter::B3 18 353 x 500 mm
QPrinter::B4 19 250 x 353 mm
QPrinter::B5 1 176 x 250 mm, 6.93 x 9.84 inches
QPrinter::B6 20 125 x 176 mm
QPrinter::B7 21 88 x 125 mm
QPrinter::B8 22 62 x 88 mm
QPrinter::B9 23 33 x 62 mm
QPrinter::B10 16 31 x 44 mm
QPrinter::C5E 24 163 x 229 mm
QPrinter::Comm10E 25 105 x 241 mm, U.S. Common 10 Envelope
QPrinter::DLE 26 110 x 220 mm
QPrinter::Executive 4 7.5 x 10 inches, 190.5 x 254 mm
QPrinter::Folio 27 210 x 330 mm
QPrinter::Ledger 28 431.8 x 279.4 mm
QPrinter::Legal 3 8.5 x 14 inches, 215.9 x 355.6 mm
QPrinter::Letter 2 8.5 x 11 inches, 215.9 x 279.4 mm
QPrinter::Tabloid 29 279.4 x 431.8 mm
QPrinter::Custom 30 Unknown, or a user defined size.
According to the wkhtmltopdf manual located here it then refers you to list of usable --page-size options which can be found here.
The page size of "DL Envelope" is 110mm x 220mm. So the page size option you need to supply to wkhtmltopdf is --page-size DLE.
I'm writing an application in Python that applies a watermark to a font file. The glyphs are non-convex polygons with holes and consist of bezier splines defined in PostScript. The watermark needs to merge with the glyphs, not overlap. I was unable to find a library to do this in Python so I'm using CGAL & C++. I have it working nicely on most glyphs, but it's mysteriously failing on others.
Initially, I was very impressed with CGAL. It looked very comprehensive and sophisticated and seemed to provide all the functionality I needed, but it suffers one fatal flaw - and I almost can't believe it - the library contains no error handling. No error codes, no exceptions, just assertions - but only in the debug build. In the release build you get a nice segmentation fault instead. Furthermore, the assertions reveal nothing about the nature of the problem.
The program fails only on certain glyphs. The letter 'e' works fine, but it crashes on 'a'. The crash occurs when I attempt to compute the union of the glyph with the watermark. There is nothing visibly wrong with the 'a' glyph. My application parses the PostScript correctly and renders it fine on a QGraphicsView.
This program needs to run on a server and its output sent directly to the customer so it must be reliable. I can't recover from an assertion failure or a segfault, so what can I do?
Even if I get it working reliably, how can I trust that it will never fail? If there was some kind of error handling in place, I could just skip the few glyphs that it fails on, leaving them unwatermarked - not ideal, but acceptable. I just don't understand what the authors of this library were thinking; they went to such tremendous effort to make the most comprehensive geometry library available only to ensure that it's completely unfit for purpose.
Currently, it's looking like I'm going to have to modify the code myself to handle the error in a sensible way, but this just seems so ridiculous.
I'm sorry if I come off as impatient, but I'm way past my deadline and my client isn't going to care about or understand these excuses.
The assertion failure is occurring on line 2141 of multiset.h:
CGAL_multiset_precondition (comp_f(object, nodeP->object) != LARGER);
It happens when I call join() on a BezierPolygonSet. My types are as follows:
typedef CGAL::CORE_algebraic_number_traits NtTraits;
typedef NtTraits::Rational Rational;
typedef NtTraits::Algebraic Algebraic;
typedef CGAL::Cartesian<Rational> RatKernel;
typedef CGAL::Cartesian<Algebraic> AlgKernel;
typedef RatKernel::Point_2 BezierRatPoint;
typedef CGAL::Arr_Bezier_curve_traits_2<RatKernel, AlgKernel, NtTraits> Traits;
typedef Traits::Point_2 BezierPoint;
typedef Traits::Curve_2 BezierCurve;
typedef CGAL::Gps_traits_2<Traits> BezierTraits;
typedef BezierTraits::X_monotone_curve_2 BezierXMonotoneCurve;
typedef BezierTraits::General_polygon_2 BezierPolygon;
typedef BezierTraits::General_polygon_with_holes_2 BezierPolygonWithHoles;
typedef CGAL::Gps_default_dcel<BezierTraits> BezierDcelTraits;
typedef CGAL::General_polygon_set_2<BezierTraits, BezierDcelTraits> BezierPolygonSet;
Any help would be much appreciated. Thanks.
EDIT:
I have a module called Geometry which wraps the CGAL code and exposes a bunch of geometric primitives (Point, Curve, LineSegment, CubicBezier, Path) and the functions:
PathList toPathList(const PolyList& polyList);
PolyList toPolyList(const PathList& paths);
The Path class has a method called computeUnion, which looks like this:
PathList Path::computeUnion(const PathList& paths1, const PathList& paths2) {
PolyList polyList1 = toPolyList(paths1);
PolyList polyList2 = toPolyList(paths2);
cgal_wrap::BezierPolygonSet polySet;
for (auto i : polyList1) {
polySet.join(i);
}
for (auto i : polyList2) {
polySet.join(i);
}
PolyList polyList;
polySet.polygons_with_holes(std::back_inserter(polyList));
return toPathList(polyList);
}
The error occurs when I call join(). The polygons are created from paths like so:
PolyList toPolyList(const PathList& paths) {
cgal_wrap::Traits traits;
cgal_wrap::Traits::Make_x_monotone_2 fnMakeXMonotone = traits.make_x_monotone_2_object();
cgal_wrap::RatKernel ratKernel;
cgal_wrap::RatKernel::Equal_2 fnEqual = ratKernel.equal_2_object();
PolyList polyList; // The final polygons with holes
cgal_wrap::BezierPolygon outerPoly;
std::list<cgal_wrap::BezierPolygon> holes;
std::list<cgal_wrap::BezierXMonotoneCurve> monoCurves;
bool first = true;
cgal_wrap::BezierRatPoint firstPoint;
// For each path in the list
for (auto i = paths.begin(); i != paths.end(); ++i) {
const Path& path = *i;
cgal_wrap::BezierRatPoint prevEndPoint;
// For each curve in the path
for (auto j = path.begin(); j != path.end(); ++j) {
const Curve& curve = **j;
std::list<cgal_wrap::BezierRatPoint> points;
if (curve.type() == LineSegment::type) {
const LineSegment& lseg = dynamic_cast<const LineSegment&>(curve);
cgal_wrap::BezierRatPoint A = lseg.A();
if (j != path.begin()) {
if (A != prevEndPoint) {
// TODO
assert(false);
}
A = prevEndPoint;
}
points.push_back(cgal_wrap::BezierRatPoint(A));
points.push_back(cgal_wrap::BezierRatPoint(lseg.B()));
}
else if (curve.type() == CubicBezier::type) {
const CubicBezier& bezier = dynamic_cast<const CubicBezier&>(curve);
cgal_wrap::BezierRatPoint A = bezier.A();
if (j != path.begin()) {
if (A != prevEndPoint) {
// TODO
assert(false);
}
A = prevEndPoint;
}
points.push_back(cgal_wrap::BezierRatPoint(A));
points.push_back(cgal_wrap::BezierRatPoint(bezier.B()));
points.push_back(cgal_wrap::BezierRatPoint(bezier.C()));
points.push_back(cgal_wrap::BezierRatPoint(bezier.D()));
}
bool bClosesCurve = false;
if (!first && Point(points.back()) == Point(firstPoint)) {
points.pop_back();
points.push_back(firstPoint);
bClosesCurve = true;
}
prevEndPoint = points.back();
cgal_wrap::BezierCurve cgalCurve(points.begin(), points.end());
std::list<CGAL::Object> monoObjs;
fnMakeXMonotone(cgalCurve, std::back_inserter(monoObjs));
// Append the x-monotone curves to the list
cgal_wrap::BezierXMonotoneCurve monoCurve;
for (auto o = monoObjs.begin(); o != monoObjs.end(); ++o) {
if (CGAL::assign(monoCurve, *o)) {
monoCurves.push_back(monoCurve);
}
}
if (!first) {
// If this curve closes the current chain, thereby creating a new polygon
if (bClosesCurve) {
// Add the new polygon to the list
cgal_wrap::BezierPolygon subPoly(monoCurves.begin(), monoCurves.end());
if (subPoly.orientation() == CGAL::COUNTERCLOCKWISE) {
if (!outerPoly.is_empty()) {
polyList.push_back(cgal_wrap::BezierPolygonWithHoles(outerPoly, holes.begin(), holes.end()));
holes.clear();
}
outerPoly = subPoly;
}
else {
holes.push_back(subPoly);
}
monoCurves.clear();
first = true;
}
}
else {
// This is the first curve in the chain - store its source point
firstPoint = cgalCurve.control_point(0);
first = false;
}
}
}
polyList.push_back(cgal_wrap::BezierPolygonWithHoles(outerPoly, holes.begin(), holes.end()));
return polyList;
}
Notice that I'm careful to ensure that the polygon boundaries have no gaps by setting the first point of curve n+1 to the last point of curve n in case they were slightly different. I was hoping this would solve the problem, but it didn't. I can't think of any other things that might make the shapes invalid.
Here is the successful merging of the 'e' glyph with the watermark (an X).
Here is what the 'a' glyph looks like. The merging fails on this glyph.
EDIT 2:
Here are the curves that make up the 'a' glyph after parsing it from PostScript. There doesn't appear to be anything wrong with it. As I said, it looks okay when rendered. The error probably occurs during the translation from this data into the CGAL types. The line segments get translated into BezierCurves with 2 control points. I will investigate further.
LineSegment[(344, 0), (409, 0)]
CubicBezier[(409, 0), (403, 24), (400, 68), (400, 161)]
LineSegment[(400, 161), (400, 324)]
CubicBezier[(400, 324), (400, 437), (330, 485), (232, 485)]
CubicBezier[(232, 485), (180, 485), (121, 472), (66, 437)]
LineSegment[(66, 437), (94, 385)]
CubicBezier[(94, 385), (127, 405), (167, 424), (224, 424)]
CubicBezier[(224, 424), (283, 424), (326, 392), (326, 320)]
LineSegment[(326, 320), (326, 290)]
LineSegment[(326, 290), (236, 287)]
CubicBezier[(236, 287), (188, 285), (150, 280), (118, 264)]
CubicBezier[(118, 264), (70, 242), (38, 199), (38, 136)]
CubicBezier[(38, 136), (38, 45), (102, -10), (188, -10)]
CubicBezier[(188, -10), (247, -10), (293, 18), (330, 53)]
LineSegment[(330, 53), (344, 0)]
LineSegment[(326, 234), (326, 114)]
CubicBezier[(326, 114), (304, 91), (260, 52), (201, 52)]
CubicBezier[(201, 52), (147, 52), (113, 88), (113, 140)]
CubicBezier[(113, 140), (113, 171), (127, 198), (154, 213)]
CubicBezier[(154, 213), (175, 224), (202, 230), (243, 231)]
LineSegment[(243, 231), (326, 234)]
EDIT 3:
Here are the 'a' glyph curves after translation into CGAL curves. Notice that they exactly match the curves before translation implying that none of them had to be split into X-monotone subcurves; they must have all been X-monotone already.
Outer boundary:
2 344 0 409 0 [1] | 344 0 --> 409 0
4 409 0 403 24 400 68 400 161 [1] | 409 0 --> 400 161
2 400 161 400 324 [1] | 400 161 --> 400 324
4 400 324 400 437 330 485 232 485 [1] | 400 324 --> 232 485
4 232 485 180 485 121 472 66 437 [1] | 232 485 --> 66 437
2 66 437 94 385 [1] | 66 437 --> 94 385
4 94 385 127 405 167 424 224 424 [1] | 94 385 --> 224 424
4 224 424 283 424 326 392 326 320 [1] | 224 424 --> 326 320
2 326 320 326 290 [1] | 326 320 --> 326 290
2 326 290 236 287 [1] | 326 290 --> 236 287
4 236 287 188 285 150 280 118 264 [1] | 236 287 --> 118 264
4 118 264 70 242 38 199 38 136 [1] | 118 264 --> 38 136
4 38 136 38 45 102 -10 188 -10 [1] | 38 136 --> 188 -10
4 188 -10 247 -10 293 18 330 53 [1] | 188 -10 --> 330 53
2 330 53 344 0 [1] | 330 53 --> 344 0
Holes:
Hole:
2 326 234 326 114 [1] | 326 234 --> 326 114
4 326 114 304 91 260 52 201 52 [1] | 326 114 --> 201 52
4 201 52 147 52 113 88 113 140 [1] | 201 52 --> 113 140
4 113 140 113 171 127 198 154 213 [1] | 113 140 --> 154 213
4 154 213 175 224 202 230 243 231 [1] | 154 213 --> 243 231
2 243 231 326 234 [1] | 243 231 --> 326 234
This polygon causes the assertion failure when added to a BezierPolygonSet. Any ideas?
You can customize error handling; see the manual.
Please attach a complete standalone program. Nothing looks wrong to me with statements you listed.
You can approximate the Bezier curves with polylines and process the whole things using polylines. If the problem is with the handling of Bezier curves, then this would solve it. If this is acceptable, it will also be more efficient.
We have fixed a bug in the CGAL component that handles Bezier curves, namely, Arr_Bezier_curve_traits_2.h.
I've been racking my brain trying to get this information from a text doc into a few different arrays. The number before each name in the txt doc is the identification number, I want to put all these into a single double array. Then put every name into a single string array. Then finally put the numbers after each name into a double 2d array with 50 rows (one for each name) and 7 columns (for the seven scores/numbers for each client). I'm not asking for anyone to do my homework for me, I just need some info on how to get started.
using namespace std;
int main() { ifstream file("client_info.txt");
string txtArray[450];
for (int i = 0; i < 450; ++i)
{
file >> txtArray[i];
}
I thought maybe I'd put all of the text into a string array then split that array into several other arrays, but realized it would be difficult to use strings, since I need the numbers to be doubles for later when I'm finding the average of the clients scores.
Here is the txt doc:
93 SMITH 739.15 634.36 257.02 639.32 376.75 360.56 666.96 81 JOHNSON 888.08 975.86 672.78 176.35 114.58 511.24 502.56 50 WILLIAMS 222.27 171.83 232.83 609.79 726.69 444.89 520.63 32 JONES 343.13 687.73 931.93 72.36 183.93 486.3 90.09 68 BROWN 623.39 968.13 67.59 528.93 703.95 329.02 875.95 24 DAVIS 97.48 296.61 568.49 990.18 448.36 567.52 179.42 21 MILLER 147.68 38.87 64.78 463.19 172.39 914.68 827.42 90 WILSON 687.7 595.19 930.52 77.27 877.45 774.44 599.83 29 MOORE 739.33 402 825.29 859.63 937.14 405.2 89.22 12 TAYLOR 976.11 531.4 731.45 815.16 518.26 858.86 832.34 31 ANDERSON 133.12 355.22 517.53 926.54 552.05 932.52 745.75 89 THOMAS 217.72 266.14 622.99 541.35 618.49 268.9 243.63 87 JACKSON 352.81 772.31 109.43 139.14 430.43 625.92 207.79 46 WHITE 650.79 367.65 915.68 848.85 912.44 603.15 704.01 75 HARRIS 708.38 70.53 34.45 409.82 288.28 735.06 140.9 85 MARTIN 701.73 643.16 766.3 198.92 805.86 802.39 239.76 67 THOMPSON 993.9 274.75 72.87 928.41 208.81 260.42 5.56 52 GARCIA 871.48 646.48 914.77 98.61 724.86 680.7 363.15 60 MARTINEZ 293.38 448.24 985.08 135.2 277.77 705.58 567.81 69 ROBINSON 914.18 688.95 112.81 270.18 950.27 607.49 915.75 76 CLARK 956.12 110.6 820.53 140.97 906.2 529.52 75.24 82 RODRIGUEZ 224.88 324.32 672.74 502.27 768.99 116.42 880.86 39 LEWIS 805.89 274.54 211.14 82.04 804.41 259.69 408.08 48 LEE 80.06 381.7 975.29 448.33 578.49 548.19 818.85 26 WALKER 657.74 0.74 741.06 533.84 887.36 38.35 619.17 55 HALL 266.9 46.42 825.89 986.01 146.96 349.07 386.64 100 ALLEN 293.22 423.57 150.53 519.25 16.96 65.54 688.44 11 YOUNG 870.69 192.46 82.19 92.46 971.38 156.49 16.48 57 HERNANDEZ 145.33 123.45 860.78 521.86 739.9 138.88 169.33 96 KING 411.31 340.93 447.04 14.26 744.1 425.83 57.87 4 WRIGHT 503.48 488.13 603.12 198.14 425.51 216.28 49.75 64 LOPEZ 296.99 744.89 270.49 138.19 897.06 374.89 831.66 62 HILL 910.95 676.68 442.98 961.03 567.6 739.49 225.26 37 SCOTT 970.31 468.48 788.85 903.66 897.93 124.04 983.01 34 GREEN 260.42 714.42 496.13 492.39 170.17 999.36 890.8 51 ADAMS 212.36 115.84 308.57 741.29 780.3 193.71 423.82 40 BAKER 316.91 671.36 398.53 190.99 424.34 457.68 584.16 47 GONZALEZ 947.9 348.88 299.11 71.82 727.49 480.59 891.51 3 NELSON 160.13 962.1 903.76 107.34 127.07 844.07 575.1 36 CARTER 981.92 250.09 5.39 866.43 182.93 135.12 224.91 78 MITCHELL 805.83 181.19 549.25 815.72 776.2 887.33 144.86 28 PEREZ 144.04 616.81 637.07 342.41 818.58 901.72 104.02 8 ROBERTS 880.38 62.34 591.34 721.18 184.64 378.08 439.94 99 TURNER 21.83 227.82 378.42 680.24 336.24 703.13 52.36 2 PHILLIPS 664.1 879.16 811.4 842.3 463.96 446.52 919.31 17 CAMPBELL 392.91 26.12 591.74 766.1 30.91 108.24 863.81 33 PARKER 359.87 606.99 61.67 188.85 474.87 159.02 907.38 30 EVANS 770.78 70.1 724.89 490.02 667.93 116.4 938.55 70 EDWARDS 507.59 698.53 15.5 251.9 340.84 246.6 233.04 44 COLLINS 803.53 580.38 966.57 941.38 249.58 562.3 725.05
To make a multideminsional array use
type arrayName [x][y];
The first number is row, second is column. You can use arrayName[0][x] to set the names you mentioned, assuming you use each row for a single name and whatever properties belong to that name. Hope this helps :)
With error checking omitted:
const int NUM_PERSONS = 50;
const int SCORES_PER_PERSON = 7;
double scores[NUM_PERSONS][SCORES_PER_PERSON];
int ids[NUM_PERSONS];
std::string names[NUM_PERSONS];
for(int i = 0; i < NUM_PERSONS; ++i) {
file >> ids[i] >> names[i];
for(int j = 0; j < SCORES_PER_PERSON; ++j) {
file >> scores[i][j];
}
}
First of all, I should state that this is a homework assignment, so while questions that give a direct answer will give me a good grade, I would prefer to know why something doesn't work, and a reason why/how I should fix it with your solution.
So here is the background for this function. I have a quarterback struct with the following information. There are ten games, which all are stored in the struct and its arrays:
struct QuarterBack{
string name;
int completions[kNumGames];
int attempts[kNumGames];
int yards[kNumGames];
int touchdowns[kNumGames];
int interceptions[kNumGames];
};
Now my goal for this problem is to use the information stored in these structs to compute the NFL Style passer ratings. For reference, wikipedia gives the following:
So here is the code I am using. It has some excessive parenthesis that I was trying to use to make sure my control was correct, but other than that I am stumped as to why I am not getting more correct answers. Below the code I will post an example file and output.
/**
* #brief printPasserRating prints the passer rating of all players
* #param players is the array holding all the players
*/
void printPasserRating(QuarterBack *players, int numPlayers){
for(int player = 0; player < numPlayers; player++){
double passerRating = 0;
int sumCompletions = 0, sumAttempts = 0, sumYards = 0,
sumTouchdowns = 0, sumInterceptions = 0;
for(int game = 0; game < kNumGames; game++){
sumCompletions += players[player].completions[game];
sumAttempts += players[player].attempts[game];
sumYards += players[player].yards[game];
sumTouchdowns += players[player].touchdowns[game];
sumInterceptions += players[player].interceptions[game];
}
double a = 0, b = 0, c = 0, d = 0;
double nums[4] = {a, b, c, d};
nums[0] = static_cast<double>((sumCompletions / sumAttempts) - 0.3) * 5;
nums[1] = static_cast<double>((sumYards / sumAttempts) - 3) * 0.25;
nums[2] = static_cast<double>(sumTouchdowns / sumAttempts) * 20;
nums[3] = 2.375 - (static_cast<double>(sumInterceptions / sumAttempts) * 25);
for(int letter = 0; letter < 4; letter++){
nums[letter] = mm(nums[letter]);
}
passerRating = (nums[0] + nums[1] + nums[2] + nums[3]) / 0.06;
cout << players[player].name << "\t" << passerRating << endl;
}
showMenu(players, numPlayers);
}
Here is the example file. Ignore the 4, as it is for a separate part of the problem. Each row is a game, and it is listed as: completions, attempts, yards, touchdowns, then interceptions.
4
Peyton Manning
27 42 462 7 0
30 43 307 2 0
32 37 374 3 0
28 34 327 4 0
33 42 414 4 1
28 42 295 2 1
29 49 386 3 1
30 44 354 4 3
25 36 330 4 0
24 40 323 1 0
Tom Brady
29 52 288 2 1
19 39 185 1 0
25 36 225 2 1
20 31 316 2 0
18 38 197 0 1
25 43 269 1 1
22 46 228 0 1
13 22 116 1 1
23 33 432 4 0
29 40 296 1 1
Drew Brees
26 35 357 2 1
26 46 322 1 2
29 46 342 3 1
30 39 413 4 0
29 35 288 2 0
17 36 236 2 1
26 34 332 5 0
30 51 382 2 2
34 41 392 4 0
30 43 305 1 1
Eli Manning
24 35 360 1 2
25 46 340 2 3
26 44 350 3 1
34 35 460 1 2
25 36 240 2 3
16 34 250 3 1
24 35 360 1 0
35 56 340 2 2
36 44 350 3 0
34 45 360 1 1
And here is the output that the function is giving me:
Any help is much appreciated, and if you need more information to help me, feel free to comment and ask. Also, as this is a homework assignment, don't assume that I am just incompetent even if I make a silly mistake. I was told that Stack Overflow has no stupid questions, and I really hope that the community can live up to that.
This math is unlikely to do what you want:
nums[0] = static_cast<double>((sumCompletions / sumAttempts) - 0.3) * 5;
nums[1] = static_cast<double>((sumYards / sumAttempts) - 3) * 0.25;
nums[2] = static_cast<double>(sumTouchdowns / sumAttempts) * 20;
nums[3] = 2.375 - (static_cast<double>(sumInterceptions / sumAttempts) * 25);
Where you've put the cast will cast the result of the division to be double after the division has been performed. But, the division itself will be an integer division.
You want something more like this:
nums[0] = (static_cast<double>(sumCompletions) / sumAttempts - 0.3) * 5.0;
nums[1] = (static_cast<double>(sumYards) / sumAttempts - 3) * 0.25;
nums[2] = (static_cast<double>(sumTouchdowns) / sumAttempts) * 20.0;
nums[3] = 2.375 - (static_cast<double>(sumInterceptions) / sumAttempts) * 25.0;
By casting one of the terms in the divide to double, the division itself upgrades to double.
Alternately, you could just declare all of these variables to be double and avoid the casts entirely. That would make the code much easier to follow. Or, just make sumAttempts into a double, as it is common to all of the four divides.
I think the issue is in code like this:
static_cast<double>((sumCompletions / sumAttempts) - 0.3)
Here, sumCompletions and sumAttempts are ints. While you're trying to do a cast to a double to avoid integer division, the cast is on the complete value of the expression rather than on the numerator or denominator. This means that the division performed is integer division, which then has 0.3 subtracted and the result, which is already a double, is then cast to a double.
To fix this, cast the numerator or denominator, not the quotient itself:
static_cast<double>(sumCompletions) / sumAttempts - 0.3
Hope this helps!