terça-feira, 3 de dezembro de 2013

Math and Physics for everyone!

Math and Physics for everyone! Learn mathematics and physics with interactive programs.
http://www.falstad.com/mathphysics.html

Matrixes ... for what?

Matrices for basic education can seem useless besides solving linear systems. It turns out that linear systems are extremely useful for solving optimization problems in industrial systems solved by Production Engineering. But arrays are the basis for many applications in computing. One of them is that I now cite the reflection of an image in its x or y axis. I found a perfect code (courtesy of Byron Kiourtzoglou) illustrating a method used in java to reflect both x and y, however, this code is only doing reflection in x. To test the code, just use simply assemble the project with an IDE like Eclipse or Netbeans and the test image in "c :/" directory with name "image.png"



package raizgeom;

/ @author Byron Kiourtzoglou
 */
import java.awt.Component;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.Transparency;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;

public class BufferedImageFlipps {

    static BufferedImage image;
    static boolean imageLoaded = false;

    public static void main(String[] args) {

  // The ImageObserver implementation to observe loading of the image

  ImageObserver myImageObserver = new ImageObserver() {

    public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) {

if ((flags & ALLBITS) != 0) {

  imageLoaded = true;

  System.out.println("Image loading finished!");

  return false;

}

return true;

    }

  };

  // The image URL - change to where your image file is located!

  String imageURL = "c:/image.png";

  /

   * This call returns immediately and pixels are loaded in the background

   * We use an ImageObserver to be notified when the loading of the image

   * is complete

   */

  Image sourceImage = Toolkit.getDefaultToolkit().getImage(imageURL);

  sourceImage.getWidth(myImageObserver);

  // We wait until the image is fully loaded

  while (!imageLoaded) {

try {

    Thread.sleep(100);

} catch (InterruptedException e) {

}

  }

  // Create a buffered image from the source image with a format that's compatible with the screen

  GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();

  GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice();

  GraphicsConfiguration graphicsConfiguration = graphicsDevice.getDefaultConfiguration();

  // If the source image has no alpha info use Transparency.OPAQUE instead

  image = graphicsConfiguration.createCompatibleImage(sourceImage.getWidth(null), sourceImage.getHeight(null), Transparency.BITMASK);

  // Copy image to buffered image

  Graphics graphics = image.createGraphics();

  // Paint the image onto the buffered image

  graphics.drawImage(sourceImage, 0, 0, null);

  graphics.dispose();

  // Flip the image vertically

  //AffineTransform tx = AffineTransform.getScaleInstance(1, -1);

 // tx.translate(0, -image.getHeight(null));

  //AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);

  //image = op.filter(image, null);

  // Flip the image horizontally

  AffineTransform tx = AffineTransform.getScaleInstance(-1, 1);

  tx.translate(-image.getWidth(null), 0);

  AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);

  image = op.filter(image, null);

  / Flip the image vertically and horizontally; equivalent to rotating the image 180 degrees

  tx = AffineTransform.getScaleInstance(-1, -1);

  tx.translate(-image.getWidth(null), -image.getHeight(null));

  op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);

  image = op.filter(image, null); */

  // Create frame with specific title

  Frame frame = new Frame("Example Frame");

  // Add a component with a custom paint method

  frame.add(new CustomPaintComponent());

  // Display the frame

  int frameWidth = 300;

  int frameHeight = 300;

  frame.setSize(frameWidth, frameHeight);

  frame.setVisible(true);

    }

    /
     * To draw on the screen, it is first necessary to subclass a Component and
     * override its paint() method. The paint() method is automatically called
     * by the windowing system whenever component's area needs to be repainted.
     */
    static class CustomPaintComponent extends Component {

  public void paint(Graphics g) {

// Retrieve the graphics context; this object is used to paint

// shapes

Graphics2D g2d = (Graphics2D) g;

/

 * Draw an Image object The coordinate system of a graphics context

 * is such that the origin is at the northwest corner and x-axis

 * increases toward the right while the y-axis increases toward the

 * bottom.

 */

int x = 0;

int y = 0;

g2d.drawImage(image, x, y, this);

  }

    }

}


 

Ideas into Education

Reference http://fundacaolemann.org.br/blog/ about ideas related to education.

For instance the following news: Google and YouTube EDU Lemann Foundation launch in Brazil

http://www.youtube.com/watch?v=YdpWbofz8T0

Learning logic 101 part 1

Learning logic 101 part 1
Why logic? Without it the mathematicians were today fighting each other to win the battle for recognition that his proof concerning a given problem is correct or true solution.

Circuits are great at explaining the basics of logic, I present to you the program. http://compscinet.org/hausen/courses/circuitos/circuit-simulator.jar soon be posting more how to use it.

Aprendendo lógica 101 parte 1

Porque lógica? Sem ela os matemáticos estariam até hoje brigando entre si para ganhar a disputa pelo reconhecimento de que sua prova referente a um dado problema é a solução correta ou verdadeira.

Circuitos são ótimos para explicar o básico da lógica, apresento-lhes o programa. 
http://www.falstad.com/circuit/  Logo mais postarei como usá-lo e aproveito aqui para agradecer aos Docentes envolvidos na produção desse software.

Thanks to Rodrigo Hausen for file import/export and many other UI improvements. Thanks to J. Mike Rollins for the Zener diode code. Thanks to Julius Schmidt for the spark gap code and some examples. Thanks to Dustin Soodak for help with the user interface improvements.