Software for rescaling map elements

[NGPU] Revetron

L1: Registered
Jul 29, 2018
7
1
Hi Everyone,

I have written a piece of software which is useful for rescaling map-elements with proportional dimensions. The program works by taking-in two vectors as its input, and then producing two equivalent orthonormal vectors (ones that are 1 unit in magnitude and at 90 degrees to each other). These can then be multiplied by any number to resize them, therefore allowing the map-maker to fully control the dimensions of the new object. To run the program, simply download the zip-file and extract the executable; it should ideally be run through Command Prompt. When prompted to type-in the vectors, type-in the elements vertically by pressing "Enter" after each value. For those who use Mac OS or Linux, I have included a copy of the C code for you to compile for your OS. Here is the code:

#include <stdio.h>
#include <math.h>

int main() {

int size, i;
printf("\nHow many dimensions are you working in: ");
scanf("%i", &size);
double A[size], B[size], C[size], D[size], total1, total2, total3, GS_factor;
total1 = 0;
total2 = 0;
total3 = 0;
GS_factor = 0;

printf("\nInsert the first vector's values:\n");
for (i=1;i<=size;i++) {
scanf("%lf", &A[i-1]);
}

printf("\nInsert the second vector's values:\n");
for (i=1;i<=size;i++) {
scanf("%lf", &B[i-1]);
}

for (i=1;i<=size;i++) {
total1 = total1 + pow(A[i-1], 2);
total2 = total2 + pow(B[i-1], 2);
}

total1 = sqrt(total1);
total2 = sqrt(total2);
for (i=1;i<=size;i++) {
C[i-1] = A[i-1]/total1;
}

//Here is where the Gram-Schmidt process occurs
for (i=1;i<=size;i++) {
GS_factor = GS_factor + (B[i-1]*C[i-1]);
}

for (i=1;i<=size;i++) {
D[i-1] = B[i-1] - ((GS_factor)*C[i-1]);
}

for (i=1;i<=size;i++) {
total3 = total3 + pow(D[i-1], 2);
}

for (i=1;i<=size;i++) {
D[i-1] = D[i-1]/sqrt(total3);
}

printf("\nThese are the two orthonormal vectors:");
printf("\nVector 1: Vector 2:");
for (i=1;i<=size;i++) {
printf("\n|%lf| |%lf|", C[i-1], D[i-1]);
}

return 0;

}
 

Attachments

  • Rescale.zip
    51 KB · Views: 204

Tumby

aa
May 12, 2013
1,087
1,196
I'm sorry but how does this help me? What on earth do I do with two orthonormal vectors?
It's cool that you managed to write this code, but I'm pretty sure nobody on this site has a use for this.
 

[NGPU] Revetron

L1: Registered
Jul 29, 2018
7
1
Well, it's primary use is for rescaling map props while retaining their dimension ratios. The post may contain some jargon, but it is not necessary that you understand it; I added it just to clarify what the program does in a very technical way.
 

Tumby

aa
May 12, 2013
1,087
1,196
You didn't understand what I'm asking. What do I actually DO with the vectors? How do I scale something in hammer along an arbitrary vector?

And what do you mean with props? TF2 does not allow for prop_static to be scaled at all. You can scale a prop_dynamic, but only uniformly in all directions (with rendering issues both in hammer and ingame).
 

[NGPU] Revetron

L1: Registered
Jul 29, 2018
7
1
When you obtain the two vectors after running the code, you take the one of the values from one the vectors (vector_value) and use the following formula, where desired_length_in_hU is the desired length of the object in hammer Units: (desired_length_in_hU/vector_value) = scale
You then multiply both vectors by the resulting "scale" value and you are done.

In all honesty, while I do not make TF2 maps regularly, my work heavily uses this type of maths and I though that it might be useful for mapping, since it is heavily used for other 3D graphics applications.