archive-edu.com » EDU » H » HWS.EDU

Total: 727

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • xModels Lab 1
    the object to the scene You only see it in its final position Later you ll see how to make an animation in which objects do seem to move but even then each individual frame of the animation is constructed as described here You ve seen that the transformation scale 5 magnifies an object by a factor of 5 To shrink an object you would use a scaling operation with a factor less than 1 as for example in square scale 0 5 The scale command can also be used with two numbers The first number gives a horizontal scaling factor and the second a vertical scaling factor For example square scale 2 5 specifies a rectangle that is 2 units wide and 5 units tall By the way the comma in 2 5 is optional The xModels applet ignores commas You can put them in if you like for human readability The transformation rotate 45 pivots an object through an angle of 45 degrees in a counterclockwise direction about the point 0 0 A negative angle would rotate the object in a clockwise direction It is possible to specify a different pivot point For example square rotate 45 about 0 5 0 5 would pivot the square about its upper right corner 0 5 0 5 instead of about 0 0 The transformation translate 3 7 moves an object 3 units to the right and 7 units up Negative numbers can be used to move the object to the left and down If the translate command is used with just one number as in translate 5 it indicates horizontal movement to the left or right For convenience there are also commands xtranslate and ytranslate for moving an object horizontally or vertically only For example square ytranslate 5 produces a square translated five units upwards You can apply a sequence of transformations to the same object simply by listing them all after the object s name in the order in which they are to be applied For example square scale 3 rotate 30 translate 5 5 specifies a square that is first magnified by a factor of 3 then rotated through 30 degrees then translated 5 units horizontally and 5 units vertically The order in which the transformations are applied can make a difference Switching the order can produce a very different picture There are other basic objects besides squares A circle is a circle of diameter one centered at 0 0 A line is a line of length one that extends from the point 0 5 0 to 0 5 0 A polygon can be specified by listing its vertices For example polygon 0 0 0 5 3 4 specifies a triangle with vertices at the points 0 0 0 5 and 3 4 These few simple shapes are all that you have to work with To make things a little more interesting you can add color to your scenes The default drawing color is black You can use a color change command to change the drawing color The drawing color that you specify remains in effect until it is changed by another color change command That is it does not just apply to the next object The color change commands include the names for the standard colors red green blue cyan magenta yellow black white and gray There is an rgb command that uses three numbers to specify the red blue and green components of a color The numbers must be in the range zero to one For example rgb 0 7 0 7 1 0 represents a light blue color There is also an hsb command that lets you specify the hue saturation and brightness levels of a color but I won t discuss the details here For example here is a scene description for an image scene that contains several objects of different colors red square scale 2 translate 5 5 cyan circle scale 5 2 rotate 30 rgb 0 4 0 2 0 2 square scale 3 rotate 30 translate 5 5 blue polygon 0 0 0 5 3 4 translate 7 7 magenta line scale 5 rotate 45 translate 5 5 You can give your scene a background color with the background command The word background must be followed by the color you want to use for a background For example background gray or background rgb 1 0 0 8 0 8 The background command should occur at most once in a scene It will have the same effect no matter where it occurs You ll find a copy of the above scene description with a pink background in the sample program SimpleObjects You can select this example from the pop up menu at the top of the applet You should render the scene to see what it looks like You should also spend some time making modifications to the scene Try changing the color of the objects or the background Try changing the numbers for the transformations Add some new objects and new transformations You should try to understand how scenes are constructed from objects transformations and colors Animation Let s face it static scenes are not all that exciting Animation makes things get a lot more interesting To make an animation in xModels you just have to do two things to your scene description put an animate command at the beginning and change some of the numbers in the scene description to number ranges Here is a simple example which can also be found in the sample scene description FirstAnimation animate 30 circle scale 1 5 red polygon 4 3 4 3 5 5 4 blue square scale 7 15 1 rotate 0 60 The first line of this scene description is an animate command which specifies that 31 frames will be rendered There are 31 frames not 30 because the number in the animate command gives the length of the animation not the number of frames There are 30 intervals between

    Original URL path: http://math.hws.edu/TMCM/java/labs/xModelsLab1.html (2016-02-07)
    Open archived version from archive


  • xModels Lab 2
    The translate command can also be used with one two or three parameters In its most general form with all three parameters it specifies motion in all three directions With one parameter it specifies movement in the x direction only and with two parameters it specifies movement in the x direction and y direction only There is a command ztranslate for moving an object in the z direction only For example square ztranslate 5 represents a square that has been moved 5 units forward out of the screen You already saw the analogous commands xtranslate and ytranslate in the previous lab Scaling and translation are pretty much the same in three dimensions as in two but rotation in three dimensions is another matter In two dimensions an object is rotated about a point A three dimensional object must be rotated about a line like a top spinning about its axis In xModels there are three rotations commands for rotation about the x axis the y axis and the z axis respectively The commands are called xrotate yrotate and zrotate The zrotate command is actually the same as the plain old rotate It is easiest to understand rotation in three dimensions by looking at examples Enter the following simple scene description into a new program in xModels and render it animate 60 square scale 10 yrotate 0 360 You will see a square rotating about its vertical axis Note that the edge of the square that is farther from you looks shorter as it should Try the same scene with the square changed to a cube Try using xrotate and zrotate instead of yrotate Next try the following example which illustrates a translation in the z direction followed by a rotation animate 60 square scale 5 ztranslate 8 yrotate 0 360 The ztranslate command moves the square 8 units forward towards you The yrotate command then sends it circling away from you and back Try using xtranslate instead of ztranslate Try xrotate and zrotate in place of yrotate Make sure that you understand what you are seeing Of course a lot of the power of xModels comes from its ability to construct complex hierarchical models using the define command You can use define to define three dimensional objects just as you used it in two dimensions You ll work with some defined objects in the exercises at the end of the lab The example program NestedSquares3D uses several levels of object definitions to create what might be the ultimate nested squares example Each square rotates on its own but it also takes part in the rotation of all the squares in which it is nested I find the result visually interesting kind of like a mobile Lathing and Extrusion Modeling real objects like cars or faces in 3D requires that they be approximated with large numbers of polygons perhaps hundreds of polygons in one object You won t want to do anything so complicated with xModels But xModels does have two

    Original URL path: http://math.hws.edu/TMCM/java/labs/xModelsLab2.html (2016-02-07)
    Open archived version from archive

  • Data Representations Applet
    is a short explanation of each of the six data displays Binary This is the most direct display of the 32 bit binary number showing a zero or one to represent each individual bit Base ten Integer A binary number can be interpreted as a normal positive integer 0 1 2 3 4 written in the base ten With 32 bits you can represent 2 32 different numbers Usually you want to use both positive and negative numbers The scheme for representing negative numbers is a bit strange It is explained in Subsection 2 2 3 of The Most Complex Machine Using 32 bits the integers from 2147483648 to 2147483647 can be represented Hexadecimal It is difficult for humans to read long strings of zeros and ones Hexadecimal numbers are a kind of shorthand for writing such strings A hexadecimal number is written using the sixteen hexadecimal digits 0 1 2 3 4 5 6 7 8 9 A B C D E and F Each hexadecimal digit stands for four bits So 0 represents 0000 1 represents 0001 2 represents 0010 E represents 1110 and F represents 1111 We could also say that in the base ten the hexadecimal digit A stands for the number 10 ten B stands for 11 eleven C stands for 12 D for 13 E for 14 and F for 15 A 32 bit binary number can be expressed as an 8 digit hexadecimal number Real Number Real numbers are numbers that can contain decimal points like 3 14159 or 234 5 or 12 0 They can also be written using scientific notation For example 2 15e12 is a way of writing 2 15 times 10 12 The representation used in computers for real numbers is very complicated And it allows some strange possibilities

    Original URL path: http://math.hws.edu/TMCM/java/DataReps/index.html (2016-02-07)
    Open archived version from archive

  • xLogicCircuits Intro
    down the right mouse button Alternatively if you have a one button mouse for example you can hold down the control key to drag a component Whenever a wire or component is hilited you can delete it by clicking on the Delete button If you delete a component that has some wires attached those wires will also be deleted There is an Undo button that you can use to get back something that you delete by mistake Note that the Undo button can only undo one operation You can edit a circuit even while the power is on Subcircuits In addition to the six standard components the scrolling component pallette can also contain circuits that have been built from these basic components and iconified using the applet s Iconify button These iconified circuits can be used as components in building other more complex circuits You can drag them onto the circuit board just like other components The applet on this page should have loaded three such iconified circuits 4 Bit Adder Clock and One Bit Mem To see inside an iconified subcircuit hilite it and then click on the Enlarge button The circuit will expand to fill the circuit board You can also just double click on the subcircuit However not all browsers respond to double clicks When you expand a circuit icon from the pallette its icon is removed from the pallette The circuit that was on the board previously is iconified and moved to the pallette unless it is empty in which case it is discarded There is only one circuit on the board at any given time You can edit the circuit while it is on the circuit board and the changes you make will be permanent even after you re iconify the circuit If the circuit on the board containes a subcircuit you can enlarge that circuit to see what is inside it This does not remove the main circuit from the board it just lets you see an enlarged part of it When you shrink the subcircuit back down to its original size the main circuit is still there For an example Enlarge the 4 Bit Adder sample circuit from the pallette You ll see that it contains four copies of a subcircuit called Adder If you hilite one of the Adder circuits and Enlarge it you can see what s inside it You ll also see a big red message Enlarged from 4 Bit Adder to remind you that what you are looking at is a part of a larger circuit It is important to understand that when you drag a subcircuit onto the circuit board what you get is a copy of the circuit from the pallette If you edit the original circuit on the pallette it doesn t affect any copies that have been made If you edit one of the copies it doesn t affect the other copies Note in particular that it s easy to get two circuits that have

    Original URL path: http://math.hws.edu/TMCM/java/xLogicCircuits/index.html (2016-02-07)
    Open archived version from archive

  • xTurtle Intro
    Complex Machine However it can also be used on its own The xTurtle language is designed to be simple enough to learn easily but complex enough to teach some important programming concepts The applet below is set up to load some sample programs Use the pop up menu in the upper left corner of the applet and click on the Run Program button to see what it does Full information

    Original URL path: http://math.hws.edu/TMCM/java/xTurtle/index.html (2016-02-07)
    Open archived version from archive

  • xModels Intro
    to learn something about geometric modeling and geometric transformations which are important in computer graphics The applet was written by David Eck for use with his introductory computer science textbook The Most Complex Machine However it can also be used on its own The applet below is set up to load some sample programs Click on the RENDER button to see the image or animation described by a program Use

    Original URL path: http://math.hws.edu/TMCM/java/xModels/index.html (2016-02-07)
    Open archived version from archive

  • Sorting with HTML Canvas
    Canvas Demo Sorting Algorithms Bubble Sort Selection Sort Insertion Sort Merge Sort Quick Sort New Sort Fast Run Pause Step Comparisons 0 Copies 0 This application has been translated into

    Original URL path: http://math.hws.edu/eck/jsdemo/sortlab.html (2016-02-07)
    Open archived version from archive


  • applet below the program The program will be translated into assembly language and the computer screen will reappear with the program in its memory The program probably appears in the form of numbers but you can change the way the contents of memory are displayed by selecting a view style from the pop up menu that is above the scrolling memory display Once the program is in memory you can run it by clicking on the Run button There is a Speed pop up menu for selecting the speed at which the program runs Alternatively you can use the Step or Cycle button to move through the execution of the program manually If you want to run the program a second time you should first click on the Set PC 0 button The PC tells the computer where to find its next instruction It has to be set to zero to point to the start of the program Each of the following instructions has a comment that says what it does lod c 30 Load the constant 30 into the AC register sto 25 Store the value 30 from AC into location 25 lod c 0 Load 0 into the AC sto 26 Store the 0 into location 26 lod i 25 The value in location 25 is an address of some memory location Get the value from that address and put it into the AC The i indicates what is called indirect addressing jmz 12 If the value in the AC is zero indicating end of the list of numbers then jump to location 12 where the program will halt add 26 Add the number in location 26 the sum of the previous numbers to the AC which contains the next number from the list sto 26 Put the

    Original URL path: http://math.hws.edu/TMCM/java/xComputer/samples/TheBasics.txt (2016-02-07)
    Open archived version from archive