#include "classes.h" // 004171d0 Vector * Vector::operator_mul(Vector *outResult, float *scalar, Vector *vector) { float scaleValue; float vectorY; scaleValue = *scalar; vectorY = vector->y; outResult->x = scaleValue * vector->x; outResult->y = scaleValue * vectorY; return outResult; } // 0067f170 Vector * Vector::ToCardinal(Vector *outResult, Vector *vec) { float vecX; float vecY; vecX = vec->x; vecY = vec->y; if (ABS(vecX) <= ABS(vecY)) { outResult->x = 0.0; if (vecY < 0.0) { outResult->y = (float)&DAT_bf800000; return outResult; } outResult->y = 1.0; return outResult; } outResult->y = 0.0; if (vecX < 0.0) { outResult->x = (float)&DAT_bf800000; return outResult; } outResult->x = 1.0; return outResult; } // 0067f2b0 Vector * Vector::mul_065(Vector *outResult, Vector *source) { outResult->x = source->x * 0.65; outResult->y = source->y * 0.65; return outResult; } // 007dd3b0 Vector * Vector::operator_assign(Vector *other) { this->x = other->x; this->y = other->y; return this; } // 00a0fe90 Vector::Vector(float x, float y) { this->x = x; this->y = y; return this; } // 00a0fea0 float Vector::Length() { float length; length = sqrtf(this->x * this->x + this->y * this->y); return length; } // 00a0fed0 float Vector::LengthSquared() { return this->x * this->x + this->y * this->y; } // 00a0ff30 float Vector::Distance(Vector *other) { float fVar1; float dx; fVar1 = other->y - this->y; dx = other->x - this->x; fVar1 = sqrtf(fVar1 * fVar1 + dx * dx); return fVar1; } // 00a0ff90 float Vector::DistanceSquared(Vector *other) { float deltaY; float deltaX; deltaY = other->y - this->y; deltaX = other->x - this->x; return deltaY * deltaY + deltaX * deltaX; } // 00a0ffc0 void Vector::Normalize() { float fVar1; float fVar2; float length; fVar1 = this->x; fVar2 = this->y; length = sqrtf(fVar1 * fVar1 + fVar2 * fVar2); if (0.0 < length) { this->x = fVar1 * (1.0 / length); this->y = fVar2 * (1.0 / length); } return; } // 00a10030 Vector * Vector::Normalized(Vector *outResult) { float fVar1; float fVar2; float length; fVar2 = this->y; outResult->x = this->x; fVar1 = outResult->x; outResult->y = fVar2; fVar2 = outResult->y; length = sqrtf(fVar1 * fVar1 + fVar2 * fVar2); if (0.0 < length) { outResult->x = fVar1 * (1.0 / length); outResult->y = fVar2 * (1.0 / length); } return outResult; } // 00a100b0 void Vector::Resize(float length) { float oldLength; oldLength = sqrtf(this->x * this->x + this->y * this->y); if (0.0 < oldLength) { this->y = (length / oldLength) * this->y; this->x = (length / oldLength) * this->x; } return; } // 00a10100 Vector * Vector::Resized(Vector *outVec, float length) { float srcX; float srcX; srcX = sqrtf(this->x * this->x + this->y * this->y); if (0.0 < srcX) { srcX = this->x; outVec->y = (length / srcX) * this->y; outVec->x = (length / srcX) * srcX; return outVec; } srcX = this->y; outVec->x = this->x; outVec->y = srcX; return outVec; } // 00a10180 float Vector::Dot(Vector *other) { return other->x * this->x + other->y * this->y; } // 00a101a0 float Vector::Cross(Vector *other) { return other->y * this->x - this->y * other->x; } // 00a10270 void Vector::Rotate(float angleDegrees) { float cosAngle; float sinAngle; float oldX; cosAngle = cos(angleDegrees * 0.017453292); sinAngle = sin(angleDegrees * 0.017453292); oldX = this->x; this->x = oldX * cosAngle - this->y * sinAngle; this->y = this->y * cosAngle + oldX * sinAngle; return; } // 00a102e0 Vector * Vector::Rotated(Vector *outVec, float angleDegrees) { float fVar1; float fVar2; float cosAngle; float sinAngle; cosAngle = cos(angleDegrees * 0.017453292); sinAngle = sin(angleDegrees * 0.017453292); fVar1 = this->x; fVar2 = this->y; outVec->x = fVar1 * cosAngle - fVar2 * sinAngle; outVec->y = fVar2 * cosAngle + fVar1 * sinAngle; return outVec; } // 00a10350 Vector * Vector::FromAngle(Vector *outVec, float angleDegrees) { float fVar1; fVar1 = cos(angleDegrees * 0.017453292); outVec->x = fVar1; fVar1 = sin(angleDegrees * 0.017453292); outVec->y = fVar1; return outVec; } // 00a10390 float Vector::GetAngleDegrees() { float angleRadians; angleRadians = atan2f(this->y,this->x); return angleRadians * 57.295776; } // 00a103c0 void Vector::Clamp(float minX, float minY, float maxX, float maxY) { float clamped; clamped = this->x; if (this->x <= minX) { clamped = minX; } if (maxX <= clamped) { clamped = maxX; } this->x = clamped; clamped = this->y; if (this->y <= minY) { clamped = minY; } if (maxY <= clamped) { clamped = maxY; } this->y = clamped; return; } // 00a103f0 Vector * Vector::Clamped(Vector *outResult, float minX, float minY, float maxX, float maxY) { float clamped; clamped = this->x; if (this->x <= minX) { clamped = minX; } if (maxX <= clamped) { clamped = maxX; } outResult->x = clamped; clamped = this->y; if (this->y <= minY) { clamped = minY; } if (maxY <= clamped) { clamped = maxY; } outResult->y = clamped; return outResult; } // 00a10420 Vector * Vector::__add(Vector *outVec, Vector *other) { outVec->x = other->x + this->x; outVec->y = other->y + this->y; return outVec; } // 00a10450 Vector * Vector::operator_add_assign(Vector *other) { this->x = other->x + this->x; this->y = other->y + this->y; return this; } // 00a10480 Vector * Vector::__sub(Vector *outResult, Vector *other) { outResult->x = this->x - other->x; outResult->y = this->y - other->y; return outResult; } // 00a104b0 Vector * Vector::operator__(Vector *other) { this->x = this->x - other->x; this->y = this->y - other->y; return this; } // 00a104e0 Vector * Vector::__mul(Vector *outResult, float *scalar) { float fVar1; float fVar2; fVar1 = *scalar; fVar2 = this->y; outResult->x = fVar1 * this->x; outResult->y = fVar1 * fVar2; return outResult; } // 00a10510 Vector * Vector::Mul(Vector *outResult, Vector *other) { outResult->x = other->x * this->x; outResult->y = other->y * this->y; return outResult; } // 00a10540 Vector * Vector::operator_mul_assign(float *scalar) { this->x = *scalar * this->x; this->y = this->y * *scalar; return this; } // 00a105a0 Vector * Vector::__div(Vector *outResult, float *divisor) { float divisorValue; divisorValue = *divisor; outResult->x = this->x / divisorValue; outResult->y = this->y / divisorValue; return outResult; } // 00a105d0 Vector * Vector::__div_assign(float *divisor) { this->x = this->x / *divisor; this->y = this->y / *divisor; return this; } // 00a10600 uint8_t Vector::operator_eq(Vector *other) { if ((this->x == other->x) && (this->y == other->y)) { return 1; } return 0; } // 00a10630 uint8_t Vector::operator_ne(Vector *other) { if ((this->x == other->x) && (this->y == other->y)) { return 0; } return 1; } // 00a10660 Vector * Vector::__unm(Vector *outResult) { outResult->x = -this->x; outResult->y = -this->y; return outResult; }