math.CHSpline

  Vector math.CHSpline( number frac, Vector point0, Vector tan0, Vector point1, Vector tan1 )

Açıklama

Kübik Hermite spline algoritması.

Argümanlar

1 number frac
0'dan 1'e kadar, spline boyunca noktanın nerede olacağını belirtir.
2 Vector point0
Spline için ilk nokta.
3 Vector tan0
Spline'ın ilk noktası için teğet.
4 Vector point1
Spline için ikinci nokta.
5 Vector tan1
Spline'ın ikinci noktası için teğet.

Döndürülen Değerler

1 Vector
Verilen kesirde kübik Hermite spline üzerindeki nokta.

Örnek

local points = { Vector( 128, 128 ), -- nokta 1 Vector( 384, 128 ), -- teğet pozisyonu 1 Vector( 128, 384 ), -- nokta 2 Vector( 384, 384 ) -- teğet pozisyonu 2 } hook.Add( "HUDPaint", "math.BezierLerp", function() local frac = RealTime() % 1 local point = math.CHSpline( frac, unpack( points ) ) surface.SetDrawColor( 255, 255, 0 ) surface.DrawRect( point.x - 4, point.y - 4, 8, 8 ) surface.DrawRect( points[1].x - 4, points[1].y - 4, 8, 8 ) surface.DrawRect( points[3].x - 4, points[3].y - 4, 8, 8 ) surface.SetDrawColor( 255, 0, 0 ) surface.DrawRect( points[2].x - 4, points[2].y - 4, 8, 8 ) surface.DrawRect( points[4].x - 4, points[4].y - 4, 8, 8 ) -- Spline'ı çiz for i=0,20 do local point = math.CHSpline( i / 20, unpack( points ) ) surface.SetDrawColor( 0, 255, 0 ) surface.DrawRect( point.x - 2, point.y - 2, 4, 4 ) end end )
Çıktı:
image.png

Tüm sunucular · GmodTR Launcher · Rehber · GMod Wiki · GmodTR nedir? · Sunucu ekle · Discord