001 /* 002 * BSplineFilter 003 * 004 * Copyright (c) 2002 Marco Schmidt. 005 * All rights reserved. 006 */ 007 008 package net.sourceforge.jiu.geometry; 009 010 /** 011 * A B-spline resample filter. 012 * @author Marco Schmidt 013 * @since 0.10.0 014 * @see Resample 015 * @see ResampleFilter 016 */ 017 public class BSplineFilter extends ResampleFilter 018 { 019 public float apply(float value) 020 { 021 if (value < 0.0f) 022 { 023 value = - value; 024 } 025 if (value < 1.0f) 026 { 027 float tt = value * value; 028 return 0.5f * tt * value - tt + (2.0f / 3.0f); 029 } 030 else 031 if (value < 2.0f) 032 { 033 value = 2.0f - value; 034 return (1.0f / 6.0f) * value * value * value; 035 } 036 else 037 { 038 return 0.0f; 039 } 040 } 041 042 public String getName() 043 { 044 return "B-Spline"; 045 } 046 047 public float getRecommendedSamplingRadius() 048 { 049 return 2.0f; 050 } 051 }