Contoh Coding Dev C++
- Contoh Program String Dev C 5
- Contoh Program String Dev C 2017
- Contoh Program String C++
- Contoh Program String Dev C Online
- Contoh Program String Dev C Pdf
- Contoh Program String Dev C Youtube
- Contoh Program String Dev C File
Posted on Updated on
Berikut ini merupakan contoh – contoh coding dalam Dev C++, diantaranya :
- Berikut ini adalah program pertama OpenGL: Rotating torus, dengan shading. Sumber berisi perhitungan Matrix 4×4 kelas, kelas matematis untuk menghasilkan suatu torus dengan normals nya. perhitungan FPS sangat tidak akurat di sini.
Di sini kamu dapat belajar gratis secara online mengenai pemrograman dari dasar sampai dapat menjadi profesional dengan menggunakan bahasa pemrograman C/C. Disertai dengan berbagai contoh program yang mudah untuk dipahami. Apr 13, 2012 Selamat datang di blog kodeprogramcpp.Pada postingan kali ini saya akan berbagi kode program C, yang dimana program ini fungsi nya untuk menentukan apakah suatu kata yang diberikan oleh user atau pengguna merupakan kata yang 'palindrom' atau bukan.Yang dimaksud dengan Palindrom adalah apabila suatu frasa, kata dibaca dari depan maupun dari belakang, tidak mengalami perubahan. Contoh Program C (String (Fungsi strcat, Fungsi strlen, Fungsi strcpy, Fungsi strupr, Fungsi strlwr)). Contoh penggunaan String Pemrograman C DASAR STRING String sangat memudahkan tugas pemogram. Dengan menggunakan string, pemogram dapat menampilkan pesan kesalahan, menampil.
Apr 02, 2019 Program di bawah ini akan kita kemas dengan studi kasus dan bagimana cara menyelesaikannya menggunkan bahsa pemrograman c. 5 Contoh program c kasir sederhana #1 Kasir dengan menggunkan diskon Buat sebuah program kasir Minimarket dengan bahasa c dengan ketentuan sebagai berikut: Program dapat menentukan jumlah barang.
Mav y k sedikit pake bahasa ingris. tutorialnya
/*****************************************************************************
*
* File: Torus.cpp
* Project: OpenGL test: Torus.exe
*
* Description: This is the Class implementation of the torus object.
* This class is designed to generate Torus 3D object. Vertex list, and face
* vertex list are created with R, r and section parameters.
*
* Author: Vedder Bruno
* Date: 09/04/2004
* URL: http://bcz.emu-france.com/
*****************************************************************************/
#include <math.h>
#include “Torus.h”
using namespace std;
#define TO_DEG *3.14159f/180.0f
/*****************************************************************
* Constructor, initialise Torus fields.
*
* Torus equations: x = (R + r * cos(v))* cos(u)
* y = (R + r * cos(v))* sin(u)
* z = r sin (v)
*
* R longest radius, r small radius, u angle relative to R
* and v angle relative to r.
*
* A section of 10 means a Torus made of 10 straight section with
* angle of 36 Degree.
*****************************************************************/
Torus::Torus(float R, float r, int section)
{
float x, y, z, u, v, du,dv;
u = 0;
v = 0;
du = 360.0f / section;
dv = 360.0f / section;
/* Allocate buffer for vertex pointer list */
vtx = new float* [section * section];
for (int i =0; i < section * section; i++)
{
vtx[i] = new float[4]; /* Allocate 4 Coord Vectors */
}
/* Allocate buffer for face’s vertex list pointer */
fl = new int* [section * section];
for (int i =0; i < section * section; i++)
{
fl[i] = new int[4]; /* Allocate 4 index Vectors */
}
/* Allocate buffer for normal pointer list */
nrml = new float* [section * section];
for (int i =0; i < section * section; i++)
{
nrml[i] = new float[4]; /* Allocate 4 Coord Vectors */
}
/* First generate vertexes */
for (int i = 0; i < section; i++)
{
for (int o = 0; o < section; o++)
{
x = (R + r * cos(v TO_DEG))* cos(u TO_DEG);
y = (R + r * cos(v TO_DEG))* sin(u TO_DEG);
z = r * sin(v TO_DEG);
v += dv;
vtx[o + i*section][0] = x;
vtx[o + i*section][1] = y;
vtx[o + i*section][2] = z;
vtx[o + i*section][3] = 1.0f;
}
v = 0;
u += du; Clear space on mac app.
}
/* Second generate face list */
for (int o = 0; o <section; o++)
for (int i = 0; i < section; i++)
{
fl[i+o*section][0] = (i + (o*section))%(section * section);
fl[i+o*section][1] = (((i+1) %section) + (o*section))%(section * section);
fl[i+o*section][2] = (((( i+1) %section ) +section) + (o*section))%(section * section);
fl[i+o*section][3] = ((i+section) + (o*section) ) %(section * section);
}
/* third generate normals list */
/* y1*z2 – y2*z1 */
/* V1^V2 = z1*x2 – z2*x1 */
/* x1*y2 – x2*y1 */
for (int i=0; i < section * section; i++)
{
float a[3];
float b[3];
/*Extract vector A */
a[0] = vtx[fl[i][0]][0] – vtx[fl[i][1]][0];
a[1] = vtx[fl[i][0]][1] – vtx[fl[i][1]][1];
a[2] = vtx[fl[i][0]][2] – vtx[fl[i][1]][2];
/*Extract vector B */
b[0] = vtx[fl[i][0]][0] – vtx[fl[i][2]][0];
b[1] = vtx[fl[i][0]][1] – vtx[fl[i][2]][1];
b[2] = vtx[fl[i][0]][2] – vtx[fl[i][2]][2];
nrml[i][0]= a[1]*b[2]-a[2]*b[1];
nrml[i][1]= a[2]*b[0]-a[0]*b[2]; Cartiglio a4 autocad lt.
nrml[i][2]= a[0]*b[1]-a[1]*b[0];
/* Normalise this vector */
float norm = sqrt(nrml[i][0]*nrml[i][0] + nrml[i][1]*nrml[i][1]+ nrml[i][2]*nrml[i][2]);
nrml[i][0] /= norm;
nrml[i][1] /= norm;
nrml[i][2] /= norm;
/* Depending on our vertex order, Normal are inverted. */
nrml[i][0] *= -1;
nrml[i][1] *= -1;
nrml[i][2] *= -1;
}
/* For Torus build from Quads, face number = vertex number */
vtx_nbr = section * section;
face_nbr = vtx_nbr;
}
float** Torus::getVertexList()
{
return vtx;
}
float** Torus::getNormalList()
{
return nrml;
}
int** Torus::getFaceVertexList()
{
return fl;
}
int Torus::getVertexNumber()
{
return vtx_nbr;
}
int Torus::getFaceNumber()
{
return face_nbr;
}
/*****************************************************************************
* File: tst.cpp
* Project: OpenGL test: Torus.exe
*
* Description: This is the main file of the Torus executable.
* It generate torus, and move it in a 3d space.
*
* Author: Vedder Bruno
* Date: 09/04/2004
* URL: http://bcz.emu-france.com/
*****************************************************************************/
#include <iostream>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <unistd.h>
#include <time.h>
#include “Matrix4x4.h”
#include “Torus.h”
using namespace std;
Contoh Program String Dev C 5
/* ASCII code for the escape key. */
#define ESCAPE 27
/* The number of our GLUT window. */
int window;
/* Prototype declarations. */
void InitGL(int Width, int Height);
void keyPressed(unsigned char key, int x, int y) ;
void DrawGLScene();
void ReSizeGLScene(int Width, int Height);
void InitGL(int Width, int Height);
float** allocateVertex(int nbr);
float thetax = 0;
float thetay = 0;
float thetaz = 0;
Matrix4x4 *xRot;
Matrix4x4 *yRot;
Matrix4x4 *zRot;
Matrix4x4 *final;
Torus *torus1;
GLfloat LightAmbient[]= { 0.0f, 0.5f, 0.0f, 1.0f };
GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };
GLfloat LightPosition[]= { 3.0f, 0.0f, -3.0f, 1.1f };
GLfloat LightParams[]= { 1.0f, 1.0f, 1.0f, 1.0f };
float **vrtx_list;
float **trans_vrtx_list;
float **nrml_list;
float **trans_nrml_list;
int **face_list;
clock_t t0;
clock_t t1;
unsigned int frame_number;
long os_tick_per_second;
char fps_string[128];
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
xRot = new Matrix4x4();
yRot = new Matrix4x4();
zRot = new Matrix4x4();
final= new Matrix4x4();
torus1 = new Torus(1.5f, 0.9f, 32);
/* Select type of Display mode: Double buffer, RGBA color, Alpha components supported, Depth buffer */
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
/* get a 120 x 120 window */
glutInitWindowSize(256, 256);
/* the window starts at the upper left corner of the screen */
glutInitWindowPosition(0, 0);
/* Open a window */
window = glutCreateWindow(“Torus”);
/* Register the function to do all our OpenGL drawing. */
glutDisplayFunc(&DrawGLScene);
/* Go fullscreen. This is as soon as possible. */
// glutFullScreen();
/* Even if there are no events, redraw our gl scene. */
glutIdleFunc(&DrawGLScene);
/* Register the function called when our window is resized. */
glutReshapeFunc(&ReSizeGLScene);
/* Register the function called when the keyboard is pressed. */
glutKeyboardFunc(&keyPressed);
/* Initialize our window. */
InitGL(256, 256);
/* t0, instant fps = now. ct0; cumulative fps = t0 */
t0 = clock();
frame_number =0;
os_tick_per_second = CLK_TCK;
/* Start Event Processing Engine */
glutMainLoop();
return 1;
}
void InitGL(int Width, int Height)
{
face_list = torus1->getFaceVertexList();
vrtx_list = torus1->getVertexList();
nrml_list = torus1->getNormalList();
trans_vrtx_list = allocateVertex( torus1->getVertexNumber() );
trans_nrml_list = allocateVertex( torus1->getFaceNumber() );
printf(“Vertex number: %dn”, torus1->getVertexNumber() );
printf(“Face number: %dn”, torus1->getFaceNumber() );
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS); // The Type Of Depth Test To Do
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window
glMatrixMode(GL_MODELVIEW);
glEnable(GL_LIGHTING);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT0, GL_POSITION,LightPosition);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
}
void ReSizeGLScene(int Width, int Height) Franchise hockey manager 4 mac download.
{
if (Height0) // Prevent A Divide By Zero If The Window Is Too Small
Height=1;
glViewport(0, 0, Width, Height); // Reset The Current Viewport And Perspective Transformation
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
}
/* The main drawing function. */
void DrawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View
glTranslatef(0.0f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0
/* Calculate transformation matrix to apply to all vertex */
Matrix4x4::getXRotationMatrix4x4(xRot,thetax);
Matrix4x4::getYRotationMatrix4x4(yRot,thetay);
Matrix4x4::getZRotationMatrix4x4(zRot,thetaz);
Matrix4x4::mulMatrix(zRot, yRot, final);
Matrix4x4::mulMatrix(final, xRot, zRot);
// Matrix4x4::getTranslationMatrix4x4(final, 1, 0, 0);
/* Apply transformation to all vertex */
for (int i = 0; i < torus1->getVertexNumber(); i++)
{
Matrix4x4::mulMatrixWithVector(vrtx_list[i], trans_vrtx_list[i], zRot);
}
/* Apply transformation to all Normals */
for (int i = 0; i < torus1->getFaceNumber(); i++)
{
Matrix4x4::mulMatrixWithVector(nrml_list[i], trans_nrml_list[i], zRot);
}
/* Start Drawing Object !*/
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glBegin(GL_QUADS);
for (int i =0; i < torus1->getFaceNumber(); i++)
{
glNormal3f(trans_nrml_list[i][0], trans_nrml_list[i][1], trans_nrml_list[i][2]);
glColor3f( 1.0f , 1.0f, 1.0f );
glVertex3f( trans_vrtx_list[face_list[i][0]][0], trans_vrtx_list[face_list[i][0]][1], trans_vrtx_list[face_list[i][0]][2]);
glColor3f( 1.0f , 0.0f, 1.0f );
glVertex3f( trans_vrtx_list[face_list[i][1]][0], trans_vrtx_list[face_list[i][1]][1], trans_vrtx_list[face_list[i][1]][2]);
glColor3f( 1.0f , 1.0f, 0.0f );
glVertex3f( trans_vrtx_list[face_list[i][2]][0], trans_vrtx_list[face_list[i][2]][1], trans_vrtx_list[face_list[i][2]][2]);
glColor3f( 0.0f , 1.0f, 1.0f );
glVertex3f( trans_vrtx_list[face_list[i][3]][0], trans_vrtx_list[face_list[i][3]][1], trans_vrtx_list[face_list[i][3]][2]);
}
glEnd(); // we’re done with the polygon (smooth color interpolation)
// we need to swap the buffer to display our drawing.
glutSwapBuffers();
thetax += 1;
thetay += 2;
thetaz += 1;
frame_number++;
t1 = clock();
if(t1 – t0 > CLK_TCK)
{
float nb_sec = (float)((float)(t1-t0) / os_tick_per_second );
sprintf(fps_string,”FPS: %3.1f”, (float)(frame_number /nb_sec ) );
glutSetWindowTitle(fps_string);
frame_number = 0;
t0 = clock();
}
}
/* The function called whenever a key is pressed. */
void keyPressed(unsigned char key, int x, int y)
{
/* sleep to avoid thrashing this procedure */
//usleep(100);
/* If escape is pressed, kill everything. */
if (key ESCAPE)
{
/* shut down our window */
glutDestroyWindow(window);
exit(0);
}
}
float** allocateVertex(int nbr)
{
float **ret = (float**) malloc ( nbr * sizeof(float*) );
for (int i =0; i < nbr; i++)
ret[ i ] = (float*)malloc( 4 * sizeof(float) );
return ret;
/*****************************************************************************
*
* File: Matrix4x4.cpp
* Project: OpenGL test: Torus.exe
*
* Description: This is the implementation of the Matrix4x4 class.
* This class is designed to handle matrix manipulation, like instantiation,
* addition, multiplication. The class can generate Identity, Rotation Matrix.
*
* Author: Vedder Bruno
* Date: 09/04/2004
* URL: http://bcz.emu-france.com/
*****************************************************************************/
#include “Matrix4x4.h”
#include <iostream>
/*****************************************************************
* Constructor, returns the Identity Matrix.
*****************************************************************/
Matrix4x4::Matrix4x4()
{
v = new float[4 * 4];
v[0] = 1; v[1] = 0; v[2] = 0; v[3] = 0;
v[4] = 0; v[5] = 1; v[6] = 0; v[7] = 0;
v[8] = 0; v[9] = 0; v[10] = 1; v[11] = 0;
v[12] = 0; v[13] = 0; v[14] = 0; v[15] = 1;
}
/*****************************************************************
* Constructor, returns an initialised Matrix.
* In: 4*4 float array containing default matrix values.
*****************************************************************/
Matrix4x4::Matrix4x4(float initData[])
{
v = new float[4 * 4];
for (int i = 0; i < 4 * 4; i++) {
v[i] = initData[i];
}
}
/*****************************************************************
* Matrix dumping utility.
* In: Matrix4x4 to dump on default stream.
*****************************************************************/
void Matrix4x4::dumpMatrix(Matrix4x4 *m)
{
for (int i = 0; i < 4; i++) {
for (int o = 0; o < 4; o++) {
Contoh Program String Dev C 2017
std::cout << m->v[o + (i * 4) ] << ” “;
}
std::cout << std::endl;
}
}
/*****************************************************************
*
* Matrix multiplication:
* In: A Matrix4x4* to be multiplied with B.
* B Matrix4x4* A’s multiplicator.
* Out:
* R Matrix4x4* To store result.
*
*****************************************************************/
void Matrix4x4::mulMatrix(Matrix4x4 *A, Matrix4x4 *B, Matrix4x4 *R)
{
/* [0,0] – [3,0] */
R->v[0] = (A->v[0] * B->v[0]) + (A->v[1] * B->v[4]) + (A->v[2] * B->v[8]) + (A->v[3] * B->v[12]);
R->v[1] = (A->v[0] * B->v[1]) + (A->v[1] * B->v[5]) + (A->v[2] * B->v[9]) + (A->v[3] * B->v[13]);
R->v[2] = (A->v[0] * B->v[2]) + (A->v[1] * B->v[6]) + (A->v[2] * B->v[10]) + (A->v[3] * B->v[14]);
R->v[3] = (A->v[0] * B->v[3]) + (A->v[1] * B->v[7]) + (A->v[2] * B->v[11]) + (A->v[3] * B->v[15]);
/* [0,1] – [3,1] */
R->v[4] = (A->v[4] * B->v[0]) + (A->v[5] * B->v[4]) + (A->v[6] * B->v[8]) + (A->v[7] * B->v[12]);
R->v[5] = (A->v[4] * B->v[1]) + (A->v[5] * B->v[5]) + (A->v[6] * B->v[9]) + (A->v[7] * B->v[13]);
R->v[6] = (A->v[4] * B->v[2]) + (A->v[5] * B->v[6]) + (A->v[6] * B->v[10]) + (A->v[7] * B->v[14]);
R->v[7] = (A->v[4] * B->v[3]) + (A->v[5] * B->v[7]) + (A->v[6] * B->v[11]) + (A->v[7] * B->v[15]);
/* [0,2] – [3,2] */
R->v[8] = (A->v[8] * B->v[0]) + (A->v[9] * B->v[4]) + (A->v[10] * B->v[8]) + (A->v[11] * B->v[12]);
R->v[9] = (A->v[8] * B->v[1]) + (A->v[9] * B->v[5]) + (A->v[10] * B->v[9]) + (A->v[11] * B->v[13]);
R->v[10] = (A->v[8] * B->v[2]) + (A->v[9] * B->v[6]) + (A->v[10] * B->v[10]) + (A->v[11] * B->v[14]);
R->v[11] = (A->v[8] * B->v[3]) + (A->v[9] * B->v[7]) + (A->v[10] * B->v[11]) + (A->v[11] * B->v[15]);
/* [0,3] – [3,3] */
R->v[12] = (A->v[12] * B->v[0]) + (A->v[13] * B->v[4]) + (A->v[14] * B->v[8]) + (A->v[15] * B->v[12]);
R->v[13] = (A->v[12] * B->v[1]) + (A->v[13] * B->v[5]) + (A->v[14] * B->v[9]) + (A->v[15] * B->v[13]);
R->v[14] = (A->v[12] * B->v[2]) + (A->v[13] * B->v[6]) + (A->v[14] * B->v[10]) + (A->v[15] * B->v[14]);
R->v[15] = (A->v[12] * B->v[3]) + (A->v[13] * B->v[7]) + (A->v[14] * B->v[11]) + (A->v[15] * B->v[15]);
}
/*****************************************************************
*
* Matrix Addition:
* In: A Matrix4x4* to be Added to B.
* B Matrix4x4* second addition operand.
* Out:
* R Matrix4x4* To store result.
*
*****************************************************************/
void Matrix4x4::addMatrix(Matrix4x4 *A, Matrix4x4 *B, Matrix4x4 *R)
{
/* [0,0] – [3,0] */
R->v[0] = A->v[0] + B->v[0];
R->v[1] = A->v[1] + B->v[1];
R->v[2] = A->v[2] + B->v[2];
R->v[3] = A->v[3] + B->v[3];
/* [0,1] – [3,1] */
R->v[4] = A->v[4] + B->v[4];
R->v[5] = A->v[5] + B->v[5];
R->v[6] = A->v[6] + B->v[6];
R->v[7] = A->v[7] + B->v[7];
/* [0,2] – [3,2] */
R->v[8] = A->v[8] + B->v[8];
R->v[9] = A->v[9] + B->v[9];
R->v[10] = A->v[10] + B->v[10];
R->v[11] = A->v[11] + B->v[11];
/* [0,3] – [3,3]*/
R->v[12] = A->v[12] + B->v[12];
R->v[13] = A->v[13] + B->v[13];
R->v[14] = A->v[14] + B->v[14];
R->v[15] = A->v[15] + B->v[15];
}
/*****************************************************************
* X axis rotation matrix:
* 1 0 0 0
* 0 cos(phi) sin(phi) 0
* 0 -sin(phi) cos(phi) 0
* 0 0 0 1
*****************************************************************/
void Matrix4x4::getXRotationMatrix4x4(Matrix4x4 *R, float phi)
{
R->v[0] = 1;
R->v[1] = 0;
R->v[2] = 0;
R->v[3] = 0;
R->v[4] = 0;
R->v[5] = (float)cos(phi * 3.14159/180);
R->v[6] = (float)sin(phi * 3.14159/180);
R->v[7] = 0;
R->v[8] = 0;
R->v[9] = (float)(-1.0 * sin(phi * 3.14159/180));
R->v[10]= (float)cos(phi * 3.14159/180);
R->v[11]= 0;
R->v[12]= 0;
R->v[13]= 0;
R->v[14]= 0;
R->v[15]= 1;
}
/*****************************************************************
* Y axis rotation matrix:
* cos(phi) 0 -sin(phi) 0 https://connectbrown821.weebly.com/call-of-duty-3-free-download-mac.html.
* 0 1 0 0
* sin(phi) 0 cos(phi) 0
* 0 0 0 1
*****************************************************************/
void Matrix4x4::getYRotationMatrix4x4(Matrix4x4 *R, float phi)
{
R->v[0] = (float) cos(phi * 3.14159/180);
R->v[1] = 0;
R->v[2] = (float)(-1.0 * sin(phi * 3.14159/180));
R->v[3] = 0;
R->v[4] = 0;
R->v[5] = 1;
R->v[6] = 0;
R->v[7] = 0;
R->v[8] = (float)sin(phi * 3.14159/180);
R->v[9] = 0;
R->v[10]= (float)cos(phi * 3.14159/180);
R->v[11]= 0;
R->v[12]= 0;
R->v[13]= 0;
R->v[14]= 0;
R->v[15]= 1;
}
/*****************************************************************
* Z axis rotation matrix:
* cos(phi) sin(phi) 0 0
* -sin(phi) cos(phi) 0 0
* 0 0 1 0
* 0 0 0 1
*****************************************************************/
void Matrix4x4::getZRotationMatrix4x4(Matrix4x4 *R, float phi)
{
R->v[0] = (float) cos(phi * 3.14159/180);
R->v[1] = (float)sin(phi * 3.14159/180);
R->v[2] = 0;
R->v[3] = 0;
R->v[4] = (float)(-1.0 * sin(phi * 3.14159/180));
R->v[5] = (float) cos(phi * 3.14159/180);
R->v[6] = 0;
R->v[7] = 0;
R->v[8] = 0;
R->v[9] = 0;
R->v[10]= 1;
R->v[11]= 0;
Contoh Program String C++
R->v[12]= 0;
R->v[13]= 0;
R->v[14]= 0;
R->v[15]= 1;
}
/*****************************************************************
* Translation matrix:
* 1 0 0 0
* 0 1 0 0
* 0 0 1 0
* Tx Ty Tz 1
*****************************************************************/
void Matrix4x4::getTranslationMatrix4x4(Matrix4x4 *T, float x, float y, float z)
{
T->v[0] = 1;
T->v[1] = 0;
T->v[2] = 0;
T->v[3] = 0;
T->v[4] = 0;
T->v[5] = 1;
T->v[6] = 0;
Contoh Program String Dev C Online
T->v[7] = 0;
T->v[8] = 0;
T->v[9] = 0;
T->v[10]= 1;
T->v[11]= 0;
T->v[12]= x;
T->v[13]= y;
T->v[14]= z;
T->v[15]= 1;
}
/*****************************************************************
*
* Multiplication with a 4 coordinates vector.
*
* [a b c d] [x] [x’]
* [e f g h] [y] [y’]
* [i j k l] x [z] = [z’]
* [m n o p] [1] [‘]
*
* In: -In is the initial vector.
* -m is the Matrix to multiply
* Out:
* -Out is a vector where new coordinate will be stored.
*
*****************************************************************/
void Matrix4x4::mulMatrixWithVector(float *In, float* Out, Matrix4x4 *m)
{
Out[0] = (m->v[0] * In[0]) + (m->v[1] * In[1]) + (m->v[2] * In[2]) +(m->v[3] * In[3]);
Out[1] = (m->v[4] * In[0]) + (m->v[5] * In[1]) + (m->v[6] * In[2]) +(m->v[7] * In[3]);
Contoh Program String Dev C Pdf
Out[2] = (m->v[8] * In[0]) + (m->v[9] * In[1]) + (m->v[10] *In[2]) +(m->v[11] * In[3]);
Contoh Program String Dev C Youtube
Out[3] = (m->v[12] *In[0]) + (m->v[13] *In[1]) + (m->v[14] *In[2]) +(m->v[15] * In[3]);
Contoh Program String Dev C File
}