Skripsiphobia

Aku nulis ini setelah liat salah satu video dari Tought Cafe Today tentang robophobia, setelah research (google) ternyata banyak banget phobia seseorang yang aneh – aneh. Nah sekarang aku nulis tentang Skripsiphobia, beneran ada? hmm ndak juga sebenarnya, setiap orang punya ketakutannya sendiri terhadap sesuatu, apapun itu dan aku disini nulis dan ngasih nama orang yang takut akan skripsi dengan sebutan “skripsiphobia” walaupun tanpa penelitian terhadap orang – orang yang mengalaminya sih, hehe. Aku akan cerita tentang ketika aku skripsi, apa aku takut ngerjain skripsi?, ndak juga sih.
Lanjutkan membaca “Skripsiphobia”

Translasi 3D OpenGL di C++

#include <GL/glut.h>
float x=0.5, y=0.5, z=0.5;
//=======================================================
void tampilan(){
glClear(GL_COLOR_BUFFER_BIT); // Menghapus layar

glBegin(GL_LINE_LOOP);
glVertex3f(0,0,0);
glVertex3f(x,0,0);
glVertex3f(x,y,0);
glVertex3f(0,y,0);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(0,0,0);
glVertex3f(0,0,z);
glVertex3f(0,y,z);
glVertex3f(0,y,0);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(x,y,0);
glVertex3f(x,y,z);
glVertex3f(x,0,z);
glVertex3f(x,0,0);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(0,0,0);
glVertex3f(0,0,z);
glVertex3f(x,0,z);
glVertex3f(x,0,0);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(x,y,0);
glVertex3f(x,y,z);
glVertex3f(0,y,z);
glVertex3f(0,y,0);
glEnd();
glBegin(GL_LINE_LOOP);
glVertex3f(0,y,z);
glVertex3f(x,y,z);
glVertex3f(x,0,z);
glVertex3f(0,0,z);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1,0.5,1);
glVertex2f(-0.1,-0.1);
glVertex2f(-0.5,-0.1);
glVertex2f(-0.5,-0.5);
glVertex2f(-0.1,-0.5);
glEnd();

glEnd();

Sleep(10);
glRotatef(1,0,0,1);
glRotatef(1,1,0,0);
glutPostRedisplay();

glFlush();
}

void tekanKeyboard(unsigned char key, int x, int y){
if(key==’a’)
glTranslatef(-0.5,0,0);

if(key==’d’)
glTranslatef(0.5,0,0);

if(key==’w’)
glTranslatef(0,0.5,0);

if(key==’s’)
glTranslatef(0,-0.5,0);

if(key == ‘z’)
glRotatef(5, 0, 0, 1);

if(key == ‘x’)
glRotatef(5, 1, 0, 0);

if(key == ‘c’)
glRotatef(5, 0, 1, 0);

glutPostRedisplay();
}
//=======================================================
int main(int argc, char** argv){
glutInit(&argc,argv);
glutInitWindowPosition(200,300);
glutInitWindowSize(500,500);
glutCreateWindow(“Dasar-dasar OpenGL dan glut “);
glutDisplayFunc(tampilan);
//glClearColor(1,1,1,0);
//gluOrtho2D(-250,250,-250,250);
glutKeyboardFunc(tekanKeyboard);
glutMainLoop();
return 0;
}
//=======================================================

Translasi 2D OpenGL di C++

#include <GL/glut.h>
float posisiY=0;
float posisiX=0;
bool turun = true;
bool jalan = false;
bool putar=false;
//=======================================================
void tampilan(){
glClear(GL_COLOR_BUFFER_BIT); // Menghapus layar
glBegin(GL_LINES);
glColor3f(0,1,0); // memberi warna
glVertex2f(0,-250);
glVertex2f(0,250);
glVertex2f(-250,0);
glVertex2f(250,0);
glVertex2f(250,250);
glVertex2f(-250,-250);
glVertex2f(-250,250);
glVertex2f(250,-250);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1,0.5,1);
glVertex2f(posisiX,posisiY);
glVertex2f(posisiX+50,posisiY);
glVertex2f(posisiX+50,50+posisiY);
glVertex2f(posisiX,50+posisiY);
glEnd();

// timer
Sleep(20); // per 100 milidetik
if(jalan){
if(turun){
posisiY = posisiY – 5;
}
else{
posisiY = posisiY + 5;
}
}

if(posisiY == -250){
turun = false;
}
if(posisiY == 250-50){
turun = true;
}

if(putar){
glRotatef(10,0,0,10);
}

glutPostRedisplay();
glFlush();
}

void tekanKeyboard(unsigned char key, int x, int y){
if(key==’q’)
exit(0);

if(key==’w’&&posisiY<250-50)
posisiY=posisiY+50;

if(key==’s’&&posisiY>-250)
posisiY=posisiY-50;

if(key==’d’&&posisiX<250-50)
posisiX=posisiX+50;

if(key==’a’&&posisiX>-250)
posisiX=posisiX-50;

if(key == ‘j’)
jalan = true;

if(key == ‘k’)
jalan = false;

// rotasi
if(key == ‘z’){
glRotatef(90, 0, 0, -250);
}
if(key == ‘x’){
glRotatef(-10, 0, 0, 10);
}
if(key == ‘c’){
glRotatef(10, 0, 0, 0);
}

//putar
if(key == ‘p’){
putar=true;
}

//glutPostRedisplay();
}
//=======================================================
int main(int argc, char** argv){
glutInit(&argc,argv);
glutInitWindowPosition(400,200);
glutInitWindowSize(500,500);
glutCreateWindow(“Dasar-dasar OpenGL dan glut “);
glutDisplayFunc(tampilan);
glClearColor(1,1,1,0);
gluOrtho2D(-250,250,-250,250);
glutKeyboardFunc(tekanKeyboard);
glutMainLoop();
return 0;
}
//=======================================================

Menggambar Geometri Primitif OpenGL di C++

#include <GL/glut.h>

//=======================================================
void tampilan(){
glClear(GL_COLOR_BUFFER_BIT); // Menghapus layar

// membuat titik
glBegin(GL_POINTS);
glVertex2f(-200,-200); // membuat titik pada koordinat (0,0)
glEnd();

// membuat garis
glBegin(GL_LINES);
glColor3f(0,1,0); // memberi warna
glVertex2f(0,0);
glVertex2f(200,200);
glVertex2f(220,-10);
glVertex2f(220,-50);
glEnd();

// membuat
glBegin(GL_LINE_STRIP);
glColor3f(1,0,0);
glVertex2f(0,0);
glVertex2f(-100,0);
glVertex2f(-100,200);
glVertex2f(0,10);
glEnd();

glBegin(GL_LINE_LOOP);
glColor3f(0,0,1);
glVertex2f(0,-100);
glVertex2f(0,-200);
glVertex2f(-100,-200);
glVertex2f(-100,-100);
glEnd();

glBegin(GL_POLYGON);
glColor3f(1,1,0);
glVertex2f(100,0);
glColor3f(1,1,0);
glVertex2f(200,0);
glColor3f(1,0,0);
glVertex2f(180,-100);
glColor3f(0,1,0);
glVertex2f(120,-100);
glEnd();

glBegin(GL_TRIANGLES);
glVertex2f(-150,-50);
glVertex2f(-200,-80);
glVertex2f(-100,-80);
glEnd();

glBegin(GL_TRIANGLE_FAN);
glVertex2f(-240,0);
glVertex2f(-200,0);
glVertex2f(-220,50);
glEnd();

glBegin(GL_TRIANGLE_STRIP);
glColor3f(1,1,0);
glVertex2f(150,-200);
glColor3f(1,0,0);
glVertex2f(100,-200);
glColor3f(1,0,1);
glVertex2f(125,-125);
glEnd();

glBegin(GL_QUADS);
glVertex2f(0,-240);
glVertex2f(-50,-240);
glVertex2f(-50,-200);
glVertex2f(0,-200);
glEnd();

glFlush();
}
//=======================================================
int main(int argc, char** argv){
glutInit(&argc,argv);
glutInitWindowPosition(400,200);
glutInitWindowSize(500,500);
glutCreateWindow(“Dasar-dasar OpenGL dan glut “);
glutDisplayFunc(tampilan);
//glClearColor(1,1,1,0);
gluOrtho2D(-250,250,-250,250);
glutMainLoop();
return 0;
}
//=======================================================

Dasar Meggambar Menggunakan OpenGL di C++

#include <GL/glut.h>

//=======================================================
void tampilan(){
glClear(GL_COLOR_BUFFER_BIT); // Menghapus layar
glBegin(GL_POLYGON);
glColor3f(255,255,255);
//for(int i=0; i<400; i++){
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glVertex2f(-0.5, -0.5);
//}
glEnd();
glBegin(GL_POINTS);
glColor3f(255,0,0);
for(int i=0; i<400; i++){
glVertex2f(0, 1.0f*i/400);
glVertex2f(0, -1.0f*i/400);
glVertex2f(1.0f*i/400, 0);
glVertex2f(-1.0f*i/400, 0);

}
glEnd();
glFlush();
}
//=======================================================
int main(int argc, char** argv){
glutInit(&argc,argv);
glutInitWindowPosition(100,100);
glutInitWindowSize(400,400);
glutCreateWindow(“Dasar-dasar OpenGL dan glut “);
glutDisplayFunc(tampilan);
glutMainLoop();
return 0;
}
//=======================================================

Super Class Persegi Panjang dan Sub Class Balok

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package superclasspersegipanjangdansubclassbalok;
// CLASS PERSEGI PANJANG
class persegiPanjang{
private int panjang,lebar;

// kontruktor 1
persegiPanjang(){
}
// kontruktor 2
persegiPanjang(int panjang, int lebar){
this.panjang=panjang;
this.lebar=lebar;
}

// mengisi nilai balok
void setPanjang(int panjang){
this.panjang=panjang;
}
void setLebar(int lebar){
this.lebar=lebar;
}

//mengambil nilai balok
int getPanjang(){
return panjang;
}
int getLebar(){
return lebar;
}

// menghitung luas
int luas(){
int luas=panjang*lebar;
return luas;
}
// menghitung skala
void skala(int perbesaran){
panjang=perbesaran*panjang;
lebar=perbesaran*lebar;
}
}

// CLASS BALOK
class balok extends persegiPanjang{
private int tinggi;

// kontruktor 1
balok(){
}
// kontrktor 2
balok(int panjang, int lebar, int tinggi){
super(panjang,lebar);
this.tinggi=tinggi;
}

// mengisi tinggi
void setTinggi(int tinggi){
this.tinggi=tinggi;
}
// mengambil tinggi
int getTinggi(){
return tinggi;
}

// menghitung luas
int luas(){
int luas=(2*getPanjang()*getLebar())+(2*getPanjang()*tinggi)+(2*getLebar()*tinggi);
return luas;
}
// menghitung skala
void skala(int perbesaran){
super.skala(perbesaran);
this.tinggi=perbesaran*tinggi;
}
// menghitung volume
int volume(){
int hasilVol=luas()*tinggi;
return hasilVol;
}

}
/**
*
* @author ANGGA
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
// persegi panjang
persegiPanjang persegi=new persegiPanjang(3,5);
System.out.println(“panjang         : “+persegi.getPanjang());
System.out.println(“lebar           : “+persegi.getLebar());
System.out.println(“LUAS            : “+persegi.luas());

persegi.skala(3);
System.out.println(” +panjang (3x)  : “+persegi.getPanjang());
System.out.println(” +lebar (3x)    : “+persegi.getLebar());

System.out.println();

// balok
balok balokku=new balok (4,6,8);
System.out.println(“panjang         : “+balokku.getPanjang());
System.out.println(“lebar           : “+balokku.getLebar());
System.out.println(“tinggi          : “+balokku.getTinggi());
System.out.println(“LUAS            : “+balokku.luas());

balokku.skala(2);
System.out.println(” +panjang (2x)  : “+balokku.getPanjang());
System.out.println(” +lebar (2x)    : “+balokku.getLebar());
System.out.println(” +tinggi (2x)   : “+balokku.getTinggi());
}

}

Queue (2) di Java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package javaapplication21;
import java.util.Scanner;
import java.util.Stack;

/**
*
* @author ANGGA
*/
public class Main {
static Scanner input=new Scanner(System.in);
static int rear=-1;
static int front=0;
static Object[] dataQueue;

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.print(“Masukkan Panjang Queue : “);
dataQueue=new Object[input.nextInt()];

push(1);
push(2);
push(3);
push(4);
push(5);
push(6);
System.out.println(“rear : “+rear);
cetak();
System.out.println(“\npeekRear : “+peekRear());
System.out.println(“peekFront : “+peekFront());
System.out.println(“pop : “+pop());
System.out.println(“pop : “+pop());
System.out.println(“rear : “+rear);
cetak();

System.out.println(“\npeekRear : “+peekRear());
System.out.println(“peekFront : “+peekFront());
clear();
System.out.println(“\npeekRear : “+peekRear());
System.out.println(“peekFront : “+peekFront());
cetak();
System.out.println(front);
}

public static void push(Object data){
if(rear<dataQueue.length-1){
dataQueue[++rear]=data;
}
else
System.out.println(“Data Sudah Penuh”);
}

public static Object pop(){
Object sementara;
if(rear>=front){
sementara=dataQueue[front];
for(int i=front;i<rear;i++){
dataQueue[i]=dataQueue[i+1];
}
rear–;
}
else
sementara=”Data Habis”;

return sementara;
}

public static Object peekRear(){
if(front<=rear){
return dataQueue[rear];
}
else
return “item Sudah Habis”;
}

public static Object peekFront(){
if(front<=rear){
return dataQueue[front];
}
else
return “item Sudah Habis”;
}

public static void clear(){
rear=-1;
front=0;
}

public static void cetak(){
if(front<=rear){
for(int i=0;i<=rear;i++){
System.out.print(dataQueue[i]+” “);
}
}
else{
System.out.println(“Stack Kosong untuk diCetak”);
}
}

}