Java tutorial
//package com.java2s; /* * This file is part of Skiggle, an online handwriting recognition * Java application. * Copyright (C) 2009-2011 Willie Lim <wlim650@gmail.com> * * Skiggle is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Skiggle is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Skiggle. If not, see <http://www.gnu.org/licenses/>. * */ import android.graphics.PointF; public class Main { public static float computeCurvatureHK2003(float x0, float y0, float x1, float y1, float x2, float y2) { double kappa = 0.0D; float lB = distanceBetween2Points(x1, y1, x0, y0); float lF = distanceBetween2Points(x1, y1, x2, y2); float thetaB = (float) Math.atan2(x0 - x1, y0 - y1); float thetaF = (float) Math.atan2(x2 - x1, y2 - y1); float delta = Math.abs(thetaB - thetaF) / 2; kappa = (1 / lB + 1 / lF) * delta / 2; return (float) kappa; } public static float distanceBetween2Points(float x1, float y1, float x2, float y2) { return PointF.length(Math.abs(x1 - x2), Math.abs(y1 - y2)); } }