Safe version now exists, some testing performed.

This commit is contained in:
Tristan Campbell 2002-08-29 21:40:44 +00:00
parent bc6775e314
commit 3e701e274e
2 changed files with 8 additions and 10 deletions

View File

@ -74,8 +74,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNormalise_00024MatrixOpD
float * sourceRecord, * destRecord;
float magnitude, magnitude_squared;
int i;
register int j;
int i, j;
for (i = 0; i < source.elements; i++)
{
@ -84,12 +83,12 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNormalise_00024MatrixOpD
sourceRecord = source.nextRecord();
destRecord = dest.nextRecord();
for (j = 0 ; j < sourceWidth*sourceHeight; i++)
for (j = 0 ; j < sourceWidth*sourceHeight; j++)
magnitude_squared += sourceRecord[j] * sourceRecord[j];
magnitude = (float) sqrt((double) magnitude_squared);
for (j = 0; j < sourceWidth*sourceHeight; i++)
for (j = 0; j < sourceWidth*sourceHeight; j++)
destRecord[j] = sourceRecord[j] / magnitude;
dest.writeRecord();

View File

@ -40,7 +40,7 @@
*/
#include <windows.h>
#include "org_lwjgl_Math_MatrixOpSubtract_MatrixOpSafe.h"
#include "org_lwjgl_Math_MatrixOpNormalise_MatrixOpSafe.h"
#include "MatrixOpCommon.h"
#include <cmath>
@ -72,8 +72,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNormalise_00024MatrixOpS
float * sourceRecord, * destRecord;
float magnitude, magnitude_squared;
int i;
register int j;
int i, j;
for (i = 0; i < source.elements; i++)
{
@ -82,12 +81,12 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Math_00024MatrixOpNormalise_00024MatrixOpS
sourceRecord = source.nextRecord();
destRecord = dest.nextRecord();
for (j = 0 ; j < sourceWidth*sourceHeight; i++)
for (j = 0 ; j < sourceWidth*sourceHeight; j++)
magnitude_squared += sourceRecord[j] * sourceRecord[j];
magnitude = (float) sqrt((double) magnitude_squared);
for (j = 0; j < sourceWidth*sourceHeight; i++)
for (j = 0; j < sourceWidth*sourceHeight; j++)
destRecord[j] = sourceRecord[j] / magnitude;
dest.writeRecord();