Tips techniques 6 random numbers and random motion
This presentation is the property of its rightful owner.
Sponsored Links
1 / 9

Tips & Techniques 6 Random Numbers and Random Motion PowerPoint PPT Presentation


  • 87 Views
  • Uploaded on
  • Presentation posted in: General

Tips & Techniques 6 Random Numbers and Random Motion. Alice. Random Numbers. Random numbers are used in certain kinds of computer programs Examples: security for web applications encryption for satellite transmissions gaming programs scientific simulations

Download Presentation

Tips & Techniques 6 Random Numbers and Random Motion

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Tips techniques 6 random numbers and random motion

Tips & Techniques 6Random Numbersand Random Motion

Alice


Random numbers

Random Numbers

  • Random numbers are used in certain kinds of computer programs

  • Examples:

    • security for web applications

    • encryption for satellite transmissions

    • gaming programs

    • scientific simulations

  • In this session, we will look at examples of how to use random numbers in animations


Built in functions

Built-in functions

  • Alice provides World-level built-in functions for generating random numbers.


Tips techniques 6 random numbers and random motion

Demo

  • Ch06Lec3PenguinRandomMoves

  • Concepts illustrated in this example

    • The random number function returns a floating point value between 0 and 1.

    • A different range of values can be obtained by using the minimumand maximum parameters.

    • The integer only option allows selection of either floating point or whole numbers.


Random 3d motion

Random 3D Motion

  • In the previous example, the penguin moves in only one direction.

  • In some animations, we want an object to move to a random location in 3D. We call this random 3D motion.

  • For example, the goldfish in this world is to swim in a random motion, where the fish can move in any direction .


Six possible directions

Six possible directions

  • Of course, six move directions are possible

    • forward, backward, left, right, up, down

  • In this example, we can eliminate backward because goldfish do not swim backward.

  • To simplify the code, we can take advantage of negative numbers.

    • For example, this instruction actually moves the goldfish right:


Storyboard

Storyboard

  • Only three move instructions are needed:

    • up (will move down if the random number is negative)

    • left (will move right if random number is negative)

    • forward (no backward motion)

  • Two parameters (min, max) will be used to restrict the motion of the fish to a nearby location-- to look like swimming.

randomMotion

Parameters:min, max

Do together

fish moves up a random number distance

fish moves left a random number distance

fish moves forward a random number distance


Tips techniques 6 random numbers and random motion

Demo

  • Ch06Lec3GoldfishRandom3DMotion

  • Concepts illustrated in this example

    • A random movement in 3D space is accomplished by three simultaneous move instructions.

    • In this example, the minimum distance of the move forward instruction is 0 (the goldfish always moves forward).

    • To call the randomMotion method, min and max values are sent as arguments to the parameters


Assignment

Assignment

  • Read Tips & Techniques 6, Random Numbers and Random Motion


  • Login