bezierInterpolation: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " \| *([^=\| ]+) * \|p1=" to " |s1= $1 |p1=")
m (Some wiki formatting)
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma3
|game1= arma3
 
|version1= 1.92
|1.92


|gr1= Math
|gr1= Math


| Gets interpolated value based on {{Wikipedia|Bézier_curve|Bézier curve}} with given control points (progress value is 0...1 for a curve that starts at pos0 and finishes at posN) <br>
|descr= Gets interpolated value based on {{Wikipedia|Bézier_curve|Bézier curve}} with given control points (progress value is 0...1 for a curve that starts at pos0 and finishes at posN) <br>
[[Image:bezierInterpolation2.jpg|400px]]
[[Image:bezierInterpolation2.jpg|400px]]


|s1= progress [[bezierInterpolation]] <nowiki>[pos0, pos1,... posN]</nowiki>
|s1= progress [[bezierInterpolation]] positions


|p1=progress: [[Number]] - interpolation value
|p1= progress: [[Number]] - interpolation value


|p2=[pos0, pos1,... posN]: [[Array]]
|p2= positions: [[Array]] of [[Array]]s in format [[Position#Introduction|Position3D]]
|p3=pos: [[Array]] in format [[Position3D]]


|r1=[[Array]] - a single point position in format [[Position3D]] based on progress value
|r1= [[Array]] - a single point position in format [[Position#Introduction|Position3D]] based on progress value


|x1= Quick demonstration that spawns some spheres around player object:<code>[[for]] "_i" from 0 to 1 step 0.05 do {
|x1= Quick demonstration that spawns some spheres around player object:
[[createVehicle]] ["Sign_Sphere10cm_F",(_i [[bezierInterpolation]] [
<sqf>
[[player]] [[modelToWorld]] [0,0,0],
for "_i" from 0 to 1 step 0.05 do {
[[player]] [[modelToWorld]] [0,2,2],
createVehicle ["Sign_Sphere10cm_F", (_i bezierInterpolation [
[[player]] [[modelToWorld]] [2,0,2],
player modelToWorld [0,0,0],
[[player]] [[modelToWorld]] [0,0,4]
player modelToWorld [0,2,2],
]),[],0,"CAN_COLLIDE"];
player modelToWorld [2,0,2],
};</code>
player modelToWorld [0,0,4]
]), [], 0, "CAN_COLLIDE"];
};
</sqf>


|x2= Create a map marker curve from 4 control points with overlap (progress is -0.5...1.5 instead of 0...1):<code>[[private]] _controlPoints = [[100,-90],[200,-30],[150,60],[100,90]] [[apply]] { [[player]] [[getRelPos]] [[Magic Variables#x|_x]] };
|x2= Create a map marker curve from 4 control points with overlap (progress is -0.5...1.5 instead of 0...1):
<sqf>
private _controlPoints = [[100,-90], [200,-30], [150,60], [100,90]] apply { player getRelPos _x };
{
{
[[private]] _marker = [[createMarkerLocal]] [<nowiki/>[[str]] [[Magic Variables#x|_x]], [[Magic Variables#x|_x]]];
private _marker = createMarkerLocal [str _x, _x];
_marker [[setMarkerTypeLocal]] "mil_objective";
_marker setMarkerTypeLocal "mil_objective";
_marker [[setMarkerTextLocal]] ("P" + [[str]] [[Magic Variables#forEachIndex|_forEachIndex]]);
_marker setMarkerTextLocal ("P" + str _forEachIndex);
}
}
[[forEach]] _controlPoints;
forEach _controlPoints;
[[for]] "_i" [[from]] -0.5 [[to]] 1.5 [[step]] 0.01 [[do]]
 
for "_i" from -0.5 to 1.5 step 0.01 do
{
{
[[private]] _marker = [[createMarkerLocal]] [<nowiki/>[[str]] _i, _i [[bezierInterpolation]] _controlPoints];
private _marker = createMarkerLocal [str _i, _i bezierInterpolation _controlPoints];
_marker [[setMarkerTypeLocal]] "mil_dot";
_marker setMarkerTypeLocal "mil_dot";
};
};
[[openMap]] [[true]];</code>
openMap true;
</sqf>


|seealso= [[linearConversion]], [[vectorLinearConversion]]
|seealso= [[linearConversion]] [[vectorLinearConversion]]
}}
}}
{{GameCategory|arma3|Scripting Commands}}

Revision as of 20:03, 3 May 2022

Hover & click on the images for description

Description

Description:
Gets interpolated value based on Bézier curve with given control points (progress value is 0...1 for a curve that starts at pos0 and finishes at posN)
bezierInterpolation2.jpg
Groups:
Math

Syntax

Syntax:
progress bezierInterpolation positions
Parameters:
progress: Number - interpolation value
positions: Array of Arrays in format Position3D
Return Value:
Array - a single point position in format Position3D based on progress value

Examples

Example 1:
Quick demonstration that spawns some spheres around player object:
for "_i" from 0 to 1 step 0.05 do { createVehicle ["Sign_Sphere10cm_F", (_i bezierInterpolation [ player modelToWorld [0,0,0], player modelToWorld [0,2,2], player modelToWorld [2,0,2], player modelToWorld [0,0,4] ]), [], 0, "CAN_COLLIDE"]; };
Example 2:
Create a map marker curve from 4 control points with overlap (progress is -0.5...1.5 instead of 0...1):
private _controlPoints = [[100,-90], [200,-30], [150,60], [100,90]] apply { player getRelPos _x }; { private _marker = createMarkerLocal [str _x, _x]; _marker setMarkerTypeLocal "mil_objective"; _marker setMarkerTextLocal ("P" + str _forEachIndex); } forEach _controlPoints; for "_i" from -0.5 to 1.5 step 0.01 do { private _marker = createMarkerLocal [str _i, _i bezierInterpolation _controlPoints]; _marker setMarkerTypeLocal "mil_dot"; }; openMap true;

Additional Information

See also:
linearConversion vectorLinearConversion

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note