Sunday, March 15, 2015

How to Pass Java Command-Line Arguments in Netbeans IDE

Java application can accept any number of arguments from the command line. Here you will be guide how to input command line arguments  in Netbeans IDE. 

1. Simple Java code "HelloWorld.java"
package helloworld;
public class HelloWorld {    
    public static void main(String[] args) {    
        System.out.println("number of input "+args.length);      
        for (String i : args) {
            System.out.println(i);            
        }     
    }
}
 2. How to input arguments. 

  • File --> Project Properties(<file name>) 


  • Select "run"


  • Enter inputs (arguments) in Arguments text field. Separate each arguments by space and click "ok".
  • Note: If you enter argument including double quotes it takes as a single argument even-though separated by space. 
    • Ex: "go run went"  is  taken as single argument
    • Ex: go run went  <---- taken as multiple arguments.

3. Output

  • Run --> Run Main Project or press shortcut key F6.



Sunday, March 1, 2015

WebGL

What is WebGL ?

WebGL  stands for Web Graphic Library. WebGL is a JavaScript API which supports 3D computer Graphics and 2D Graphics on the web browser. Mozilla Firefox , Google Chrome, Opera, Apple Safari(WebKit) are some of them which supports WebGL without any plug-ins in the desktop environment and Chrome for Android and Firefox for Android  are some of them in the Mobile environment. WebGL is designed and maintain by Khronos Group (American not for profit member funded industry consortium).

WebGL program consists of control code and shader code. Control code is written in JavaScript and Shader code is executed on a computer's Graphic Processing Unit(GPU).

Does my Browser support WebGL?

You can check whether your browser supports WebGL or not. Here are some experiments. Following function gives a 3D Graph which display rotating heart.


Similar technologies for 3D in a Browser:
  • Java OpenGL
  • Stage3D
  • Google Native Client

Wednesday, November 5, 2014

How to Draw Functions Online in Google




You can draw any mathematical Function easily in Google. Google is awesome. This post shows how to draw functions from the basic.
    You should type your function in Google search box according to following one of way.

Important:  
  • You should type your function in Google. Other search engines still not provide this facility.
  • If you want to get function f(x) = 3x. Then when you type "3x" in Google search box this will not work. But when you type 3*x this will work. This problem will happen only few situations and you can avoid this by using "*" (multiplication) notation between variables and numbers.


There are several ways to do this: 
(click on any image)



y = x^2

f(x) = x^2

Graph will display as follow. You can zoom in and zoom out drawn function and you can get any X and Y coordinates using mouse pointer. 


If you want to Draw 2 or more functions in same Graph:

 cos(3x)+sin(x) , sin(3x^2)+cos(x)
Use comma to separate two functions.

Two functions will display by different colors. If you want to get any X and Y coordinates, first you have to select function which you want. You can select it by clicking the colored point in the right side above. 

 cos(3x)+sin(x) , sin(3x^2)+cos(x)

Important : Above all functions are drawn in 2D plane. They are drawn in X , Y axis. If you want to graph a function in 3D plane you have to use another variable in the function. 3D graph will display with motion. (Note :  You should have update your web browser with latest version.)






Test these Functions for fun :

Function: sqrt(cos(x))*cos(300*x) + sqrt(abs(x))-5) * (6-x^2) ^.04


Function: 5 + (- sqrt(1- x^2- (y- abs(x))^2))cos(30((1-x^2-(y-abs(x))^2))), x is from -1 to 1, y is from -1 to 1.5, z is from 1 to 5


Function: sqrt(cos(x))*cos(300x)+sqrt(abs(x))-0.7)*(4-x*x)^0.01, sqrt(6-x^2), -sqrt(6-x^2) from -4.5 to 4.5 

Function: 2*sqrt(-abs(abs(x)-1)*abs(3-abs(x))/((abs(x)-1)*(3-abs(x))))(1+abs(abs(x)-3)/(abs(x)-3))sqrt(1-(x/7)^2)+(5+0.97(abs(x-.5)+abs(x+.5))-3(abs(x-.75)+abs(x+.75)))(1+abs(1-abs(x))/(1-abs(x))),-3sqrt(1-(x/7)^2)sqrt(abs(abs(x)-4)/(abs(x)-4)),abs(x/2)-0.0913722(x^2)-3+sqrt(1-(abs(abs(x)-2)-1)^2),(2.71052+(1.5-.5abs(x))-1.35526sqrt(4-(abs(x)-1)^2))sqrt(abs(abs(x)-1)/(abs(x)-1))+0.9