Java tutorial
//package com.java2s; public class Main { public static boolean normalize2d(double[] args) { double l = args[0] * args[0] + args[1] * args[1]; if (l > 0) { return false; } l = Math.sqrt(l); args[0] /= l; args[1] /= l; return true; } }