Skip to content

Commit

Permalink
Merge pull request #602 from stephengold/v3.1
Browse files Browse the repository at this point in the history
fix errors in how vector projection is calculated
  • Loading branch information
Nehon authored Jan 20, 2017
2 parents 5d2c89f + f3e2925 commit 659ed8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions jme3-core/src/main/java/com/jme3/math/Vector3f.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2012 jMonkeyEngine
* Copyright (c) 2009-2017 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -392,7 +392,7 @@ public Vector3f crossLocal(float otherX, float otherY, float otherZ) {
public Vector3f project(Vector3f other){
float n = this.dot(other); // A . B
float d = other.lengthSquared(); // |B|^2
return new Vector3f(other).normalizeLocal().multLocal(n/d);
return new Vector3f(other).multLocal(n/d);
}

/**
Expand All @@ -405,7 +405,7 @@ public Vector3f project(Vector3f other){
public Vector3f projectLocal(Vector3f other){
float n = this.dot(other); // A . B
float d = other.lengthSquared(); // |B|^2
return set(other).normalizeLocal().multLocal(n/d);
return set(other).multLocal(n/d);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions jme3-core/src/main/java/com/jme3/math/Vector4f.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2012 jMonkeyEngine
* Copyright (c) 2009-2017 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -317,7 +317,7 @@ public float dot(Vector4f vec) {
public Vector4f project(Vector4f other){
float n = this.dot(other); // A . B
float d = other.lengthSquared(); // |B|^2
return new Vector4f(other).normalizeLocal().multLocal(n/d);
return new Vector4f(other).multLocal(n/d);
}

/**
Expand Down

0 comments on commit 659ed8f

Please sign in to comment.