Android examples for java.lang:Math Matrix
Normalize Vector src Matrix to dst Matrix
//package com.java2s; import android.opengl.Matrix; public class Main { /**//from ww w . j ava2s .c om * Normalize Vector srcM to dstM * * @param dstM The destination vector * @param dstOffset The destination vector offset * @param srcM The source vector * @param srcOffset The source vector offset */ public static final void normalizeV(final float[] dstV, final int dstOffset, final float[] srcV, final int srcOffset) { //android.util.Log.d(TAG,"normalizeV()"); final float length = Matrix.length(srcV[srcOffset], srcV[srcOffset + 1], srcV[srcOffset + 2]); if (length > 0) { dstV[dstOffset] = srcV[srcOffset] / length; dstV[dstOffset + 1] = srcV[srcOffset + 1] / length; dstV[dstOffset + 2] = srcV[srcOffset + 2] / length; } dstV[dstOffset + 3] = 1f; } }