Forgot password?

Create an account!


« back

General – help(stucture of script)


Please log in to write a message.

  • 3. fatsa29 (Feb 28, 2011 22.04):

    Does really exsist any similar script for noise?
    should i have to create on my own a script?

  • 2. Johannes (Feb 28, 2011 21.35):

    hi, looks like a class of the 3dpoint with constructors, properties, methods,... you don't need to write a script for a desciption of a 3d point. sounds like reinvent the wheel;).
    it defines a point with all properties.
    the script (beside the example) draws not even a point. it is only a very general description.


  • 1. fatsa29 (Feb 28, 2011 20.52):

    I am a beginer of script and now i m working with my thesis that is about noise and architecture.What i need to know is how input a script that have found on i-net about noise functions that i dont know exactly the stucture of the script or can anyboby help me by sending him the script on notepad and show the way that should structure it in rhino?Or at least can samobady to explain me what is happening?

    here is the script

    The Point3 class defines the characteristics of points in 3D space. These values are also known as 3D vectors, and contain 3 component floating point numbers. All the coordinates passed to and from 3ds Max are in these values. See also 2D and 3D Point Literals.
    [ <expr>, <expr>, <expr> ]

    [x, y, z]
    [10, 10, 10]
    [sin x, cos y, tan z]
    x_axis -- equivalent to [1,0,0]
    y_axis -- equivalent to [0,1,0]
    z_axis -- equivalent to [0,0,1]
    point3 <x> <y> <z>
    <color> as point3
    <point3>.x : Float -- the x coordinate
    <point3>.y : Float -- the y coordinate
    <point3>.z : Float -- the z coordinate
    <point3> == <point3>
    <point3> != <point3>

    <point3> + <point3_or_number>
    <point3> - <point3_or_number>
    <point3> * <point3_or_number>
    <point3> / <point3_or_number>
    Standard vector arithmetic. If the second operand is a number, the operation is performed on each component of the value.
    <point3> * <matrix3>
    Transforms point3 into the coordinate system specified by matrix3.
    <point3> * <quat>
    rotates point3
    - <point3>
    unary minus
    Returns a component of the Point3 as a float. Valid range on the index is 1 to 3.
    <point3>[<integer>] = <float>
    Sets a component of the Point3 to the float. Valid range on the index is 1 to 3.
    copy <point3>
    Creates a new copy of the point3 value.
    newPos = copy oldPos
    The new value contains a copy of the input point3 value, and is independent of the input point3 value.
    Vector Length
    length <point3>
    Returns the length of the vector.
    Vector Dot Product
    dot <point3> <point3>
    Returns the vector dot product.
    The geometric interpretation of the dot product is the length of the projection of the first vector onto the unit vector of the second vector. Obviously, when the two vectors are perpendicular, the dot product is 0.0.
    The dot product is commutative, this means that dot X Y == dot Y X.
    The dot product is associative, this means that dot (r*X) Y == r*(dot X Y)
    The dot product is distributive, this means that dot X (Y+Z) == (dot X Y) + (dot X Z)
    Since the dot product of two normal vectors is the cosine of the angle between them, the dot product can be used conveniently to calculate the angle between two vectors:
    fn GetVectorsAngle v1 v2 =
    theAngle = acos(dot (normalize v1) (normalize v2))

    GetVectorsAngle [10,0,0] [10,20,0]
    Vector Cross Product
    cross <point3> <point3>
    Returns the vector cross product.
    The cross product is a third vector which is always perpendicular to the plane defined by the two vectors, with orientation determined by the right-hand rule.
    The cross product can be expressed as the length of the first vector multiplied by the length of the second vector, multiplied by the sine of the angle between the two vectors. Because of this, the cross product of parallel vectors is 0.0 (since sin 0.0 == 0.0)
    The cross product is also equal to the Area of the parallelogram formed by the two vectors. Obviously, if the two vectors are edges of a face, the cross product is the normal vector to that face (a vector perpendicular to the face) with length equal to the Area of the face multiplied by 2.
    The cross product is anticommutative, this means that cross X Y == cross -Y X
    The cross product is associative, this means that cross (r*X) Y == r*(cross X Y)
    The cross product is distributive, this means that cross X (Y+Z) == (cross X Y) + (cross X Z)
    How do I align the UVW_Modifier's Gizmo to a selected face?
    Normalize Vector
    normalize <point3>
    Returns the point3 value normalized such that the vector length equals 1.
    b = [100,30.5,41.3] -- take some Point3 value
    normalB1 =normalize b -- get the normalized vector
    length normalB1 -- check the length, should be 1.0
    1.0 -- It is!
    normalB2 = b / (length b) -- Do-It-Yourself Normalize...
    [0.889603,0.271329,0.367406] -- same value
    length normalB2 -- of course, the length is also 1.0
    Distance Between Two Points / Vectors
    distance <point3> <point3>
    Returns the distance between the points, equivalent to the length of (point 2 - point 1).
    a = [10,20,30]
    b = [100,30.5,41.3]
    distance a b -- returns 91.3123
    distance b a -- returns 91.3123
    length (b-a) -- returns 91.3123
    length (a-b) -- returns 91.3123
    Pseudo-Random Point / Vector
    random <point3> <point3>
    Generates a pseudo-random point between the given points.
    If point A and point B are seen as the corners of a world-oriented bounding box, the random points will NOT reside on the vector B-A but will fill in the volume of the bounding box!
    a = [-10,-20,-30] -- define point A
    b = [20,30,50] -- define point B
    p1 = Point pos:a -- create a Point Helper at point A
    p2 = Point pos:b -- create a Point Helper at point B
    -- create 2000 spheres at random positions between point A and B
    for i = 1 to 2000 do
    sphere pos:(random a b) radius:2 wirecolor:blue

    Arbitrary Axis Matrix
    arbAxis <point3>
    Returns a Matrix3 value representing an arbitrary axis system using point3 as the "up" direction.
    Matrix From Normal
    matrixFromNormal <point3>
    Returns a Matrix3 value with the normal specified by the given point as the Z axis. The translation portion of the Matrix3 value will be [0,0,0]. The components of the scale portion are the inverse of the values required to normalize the point3 value.
    See How Do I Get the Local Rotation of a Face? for an example.
    MatrixFromNormal [0,0,1]
    MatrixFromNormal [0,1,1]
    will return
    (matrix3 [1,0,0], [0,1,0], [0,0,1], [0,0,0])
    (matrix3 [0,-0.707107,0.707107] [1.41421,0,0] [0,1,1] [0,0,0])
    3D Noise Functions
    noise3 <point3>
    A floating point noise function over 3D space, implemented by a pseudo-random tricubic spline. The return value is in the range -1.0 to +1.0. Given the same point3 value, the noise3() function always returns the same value.
    noise4 <point3> <phase_float>
    The same function as noise3 in which the phase can be varied using the second parameter. The return value is in the range -1.0 to +1.0.
    turbulence <point3> <frequency_float>
    This is a simple fractal-loop turbulence built on top of the noise3 function. The second parameter controls the frequency of the turbulence. The return value is in the range 0.0 to +1.0.
    fractalNoise <point3> <H_float> <lacunarity_float> <octaves_float>
    This is a fractal function of 3D space implemented using fractional Brownian motion. The function is homogeneous and isotropic. It returns a float.
    The parameters are as follows:
    point3 - The point in space at which the noise is computed.
    H_float - The fractal increment parameter in the range [0,1]. When H_float is 1 the function is relatively smooth; as H_float goes to 0, the function approaches white noise.
    lacunarity_float - The gap between successive frequencies, best set at 2.0.
    octaves_float - The number of frequencies in the function.
    All the noise functions are based on code and algorithms in the book "Texturing and Modeling: A Procedural Approach", Musgrave, Peachey, Perlin and Worley. Academic Press, ISBN: 0-12-228760-6.
    The following script shows the use of various literals, constructors, properties, operators, and methods of the Point3 class.
    The following script was written as a test bed for the noise functions. This script displays a 2 dimensional slice of the noise function output as a bitmap. By changing the noise parameters in lines 4 through 10, and specifying which noise function to evaluate in line 12, you can see the effects of changes in the parameters and using different noise functions.
    -- noise functions test bed
    b_width=320 -- specify size of bitmap
    size=10. -- total distance covered by each row and column
    z=0. -- z coordinate of 2D slice
    phase=0.5 -- noise4 parameter
    frequency=10. -- turbulence parameter
    fract_interval=.5 -- fractalNoise parameters
    whichfunc=1 -- 1 = noise3; 2 = noise4; 3 = turbulence; 4 = fractalNoise
    b=bitmap b_width b_height -- create the bitmap
    for h=0 to (b_height-1) do -- step through each row of the bitmap
    h_norm=(h as float/(b_height-1))*size -- calculate y coordinate
    row = for w=0 to (b_width-1) collect -- collect row of pixel colors
    w_norm=(w as float/(b_width-1))*size -- calculate x coordinate
    noise_val = case whichfunc of -- store result of selected function
    1: noise3 [w_norm, h_norm , z]
    2: noise4 [w_norm, h_norm , z] phase
    3: turbulence [w_norm, h_norm , z] frequency
    4: fractalNoise [w_norm, h_norm , z] fract_interval lacunarity octaves
    noise_val = 0.5*(1.+noise_val) -- convert output range to 0. to 1.
    white*noise_val -- and multiply by color white
    setpixels b [0,h] row -- store row of pixels in bitmap
    display b -- display bitmap in VFB


Why are these buttons gray?