Skip to content

Commit 659ed8f

Browse files
authored
Merge pull request #602 from stephengold/v3.1
fix errors in how vector projection is calculated
2 parents 5d2c89f + f3e2925 commit 659ed8f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

jme3-core/src/main/java/com/jme3/math/Vector3f.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2012 jMonkeyEngine
2+
* Copyright (c) 2009-2017 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -392,7 +392,7 @@ public Vector3f crossLocal(float otherX, float otherY, float otherZ) {
392392
public Vector3f project(Vector3f other){
393393
float n = this.dot(other); // A . B
394394
float d = other.lengthSquared(); // |B|^2
395-
return new Vector3f(other).normalizeLocal().multLocal(n/d);
395+
return new Vector3f(other).multLocal(n/d);
396396
}
397397

398398
/**
@@ -405,7 +405,7 @@ public Vector3f project(Vector3f other){
405405
public Vector3f projectLocal(Vector3f other){
406406
float n = this.dot(other); // A . B
407407
float d = other.lengthSquared(); // |B|^2
408-
return set(other).normalizeLocal().multLocal(n/d);
408+
return set(other).multLocal(n/d);
409409
}
410410

411411
/**

jme3-core/src/main/java/com/jme3/math/Vector4f.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2012 jMonkeyEngine
2+
* Copyright (c) 2009-2017 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -317,7 +317,7 @@ public float dot(Vector4f vec) {
317317
public Vector4f project(Vector4f other){
318318
float n = this.dot(other); // A . B
319319
float d = other.lengthSquared(); // |B|^2
320-
return new Vector4f(other).normalizeLocal().multLocal(n/d);
320+
return new Vector4f(other).multLocal(n/d);
321321
}
322322

323323
/**

0 commit comments

Comments
 (0)