This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://cameroncarson.com/nuke-wave-expressions/ | |
-- https://davemne.wordpress.com/2011/05/16/nuke-wave-expressions-to-copy-and-paste/ | |
fn BuildBounceArc = | |
( | |
waveWidth = 10 | |
minVal = 0 | |
maxVal = 10 | |
numSamples = 20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- biasStrength : range:[-1,1,0] | |
-- biasPower : range:[1,100,0] | |
fn CalculateBias val:0.0 bias:0.0 biasPower:1 = | |
( | |
if bias < 0 then 1 - (pow (1 - val) (1 - biasPower*bias)) else (pow val (1 + biasPower * bias)) | |
) | |
fn BiasTest = | |
( | |
count = 20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numSteps = 20 | |
height = 15.0 --radius | |
width = 30.0 --radius | |
smoothness = .5 | |
delete objects | |
for i = 0 to numSteps do | |
( | |
ang = (180.0 / numSteps) * i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
local theObjects = objects as array | |
local count = theObjects.count | |
local center = [0, 0, 0] | |
for obj in theObjects do center += obj.pos | |
center /= count | |
fn radialSort obj1 obj2 = | |
in coordSys (transMatrix center) (cross obj2.pos obj1.pos).z | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* How to rotate a vector around another vector x degrees? */ | |
staticVector = normalize (point3 1 1 1) | |
rotatingVector = normalize (point3 0 1 1) | |
centerOfRotatoin = [0,0,0] | |
x = 30 | |
--use static vector and rotating vector to derive a 3rd axis. | |
finalVector= cross staticVector rotatingVector | |
--contruct a matrix 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Option 1 | |
fn GetVectorsAngle v1 v2 = | |
( | |
theAngle = acos(dot (normalize v1) (normalize v2)) | |
) | |
vA = obj2.pos - obj1.pos -- vector between two objects | |
vA = obj3.pos - obj1.pos -- vector between two objects | |
GetVectorsAngle vA vB | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delete objects | |
target = sphere pos:[20,20,20] radius:2 | |
n = teapot radius:2 pos:[6,35,0] | |
rotate n (angleaxis -68.2351 [0.808965,0.587747,0.0113632]) | |
-- rotate teapot on local z axis so it points towards the vector (sphere position) | |
theDir = normalize (target.pos - n.pos) --a vector pointing from teapot to sphere position | |
theZ = normalize (n.transform.row3) --the local Z axis | |
theCross = cross theDir theZ --a vector perpendicular to both the Z and the direction vector | |
theDir2 = normalize (cross theZ theCross) --a vector perpendicular to the Z and the cross product = projection of the direction in local XY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn GetVectorsAngle v1 v2 = | |
( | |
theAngle = acos(dot (normalize v1) (normalize v2)) | |
) | |
fn PlaceAlongVector pos:[0,0,0] vec:[0,0,1] offset:0 = | |
( | |
pos + (normalize (vec)) * offset | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try(destroyDialog rlTest)catch() | |
rollout rlTest "test" | |
( | |
spinner uiWidth "Width" range:[-1e6,1e6,15.0] type:#worldUnits | |
spinner uiHeight "Height" range:[-1e6,1e6,5.0] type:#worldUnits | |
spinner uiSmoothness "Smoothness" range:[-1e3,1e3,0] type:#float | |
spinner uiSamples "Samples" range:[1,1e4,6] type:#integer | |
spinner uiDegrees "Degrees" range:[0,180,180] type:#float | |
fn BuildArc = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn GetVectorsAngle v1 v2 = | |
( | |
theAngle = acos(dot (normalize v1) (normalize v2)) | |
) | |
fn PlaceAlongVector pos:[0,0,0] vec:[0,0,1] offset:0 = | |
( | |
pos + (normalize (vec)) * offset | |
) |