bezierInterpolation: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(WIP - someone who has knowledge of this please write more information)
 
m (Text replacement - "[[Image:" to "[[File:")
 
(46 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|=
{{RV|type=command
____________________________________________________________________________________________


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


|1.92|Game Version =(number surrounded by NO SPACES)
|gr1= Math


|arg= |Multiplayer Arguments =("local" or "global")
|descr= Gets interpolated value based on {{Link|https://en.wikipedia.org/wiki/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>
[[File:bezierInterpolation2.jpg|400px]]


|eff= |Multiplayer Effects =("local" or "global")
|s1= progress [[bezierInterpolation]] positions


|exec= |Multiplayer Execution =("server" or empty)
|p1= progress: [[Number]] - interpolation value
____________________________________________________________________________________________


| Gets interpolated value based on bezier curve with given control points (progress is 0-1){{wip}} |Description=
|p2= positions: [[Array]] of [[Array]]s in format [[Position#Introduction|Position3D]]
____________________________________________________________________________________________


| progress [[bezierInterpolation]] <nowiki>[[x1, y1], ... [xn, yn]]</nowiki> |Syntax=
|r1= [[Array]] - a single point position in format [[Position#Introduction|Position3D]] based on progress value


|p1=progress: [[Number]]
|x1= Quick demonstration that spawns some spheres around player object:
<sqf>
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"];
};
</sqf>


|p2=<nowiki>[[x1, y1], ... [xn, yn]]</nowiki>: [[Array]]
|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 [str _x, _x];
_marker setMarkerTypeLocal "mil_objective";
_marker setMarkerTextLocal ("P" + str _forEachIndex);
}
forEach _controlPoints;


| [[Array]] |Return Value=
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;
</sqf>


|x1= <code></code> |Example 1=
|seealso= [[linearConversion]] [[vectorLinearConversion]]
____________________________________________________________________________________________
 
|mp= - |Multiplayer Behaviour=
 
|  |See Also=
}}
}}
<dl class="command_description">
<!-- BEGIN Note Section -->
<!-- For example:
<dd class="notedate">Posted on Month Day, Year - Time (UTC)</dd>
<dt class="note">'''[[User:User Name|User Name]]'''</dt>
<dd class="note">This is an example note. It is true and verifiable, and contains a little code snippet.
<code>[[if]] ([[_this]] == anExample) [[then]] { [[hint]] "Leave it here for others to read"; };</code></dd>
-->
<!-- END Note Section -->
</dl>
<h3 style="display:none">Bottom Section</h3>
<!-- Appropriate categories go here -->
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 00:11, 21 November 2023

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