package { import flash.geom.Vector3D; /** * ... * @author mas */ public class BezierSegment3D { public var a:Vector3D; public var b:Vector3D; public var c:Vector3D; public var d:Vector3D; public function BezierSegment3D($a:Vector3D, $b:Vector3D, $c:Vector3D, $d:Vector3D) { a = $a; b = $b; c = $c; d = $d; } public function getValue($t:Number):Vector3D { var t:Number = $t; var ret:Vector3D = new Vector3D; ret.x = a.x * Math.pow((1 - t), 3) + 3 * b.x * t * Math.pow((1 - t), 2) + 3 * c.x * Math.pow(t, 2) * (1 - t) + d.x * Math.pow(t, 3); ret.y = a.y * Math.pow((1 - t), 3) + 3 * b.y * t * Math.pow((1 - t), 2) + 3 * c.y * Math.pow(t, 2) * (1 - t) + d.y * Math.pow(t, 3); ret.z = a.z * Math.pow((1 - t), 3) + 3 * b.z * t * Math.pow((1 - t), 2) + 3 * c.z * Math.pow(t, 2) * (1 - t) + d.z * Math.pow(t, 3); return ret; } } }