int main(){
	int x, y;
	POINT P1, P2;
	x = 2;
	y = 3;
	printf("Nilai yang akan dimasukkan ke titik 1 x = %d, y = %d\n", x, y);
	P1 = MakePOINT(x,y);
	printf("Nilai titik 1 x = %d, y = %d\n", Absis(P1), Ordinat(P1));
	printf("Hasil fungsi TulisPOINT untuk titik 1 : ");
	TulisPOINT(P1);
	puts("");
	x = 1;
	y = 4;
	printf("Nilai yang akan dimasukkan ke titik 1 x = %d, y = %d\n", x, y);
	P2 = MakePOINT(x,y);
	puts("Tes  fungsi EQ dan NEQ (0 = false, 1 = true)");
	printf("EQ titik 1 dan 2 adalah %d\n", EQ(P1,P2));
	printf("NEQ titik 1 dan 2 adalah %d\n", NEQ(P1,P2));
	x = 2;
	y = 3;
	printf("Nilai yang akan dimasukkan ke titik 1 x = %d, y = %d\n", x, y);
	P2 = MakePOINT(x,y);
	puts("Tes  fungsi EQ dan NEQ (0 = false, 1 = true)");
	printf("EQ titik 1 dan 2 adalah %d\n", EQ(P1,P2));
	printf("NEQ titik 1 dan 2 adalah %d\n", NEQ(P1,P2));
	return 0;
}
Beispiel #2
0
void DrawTriangle(Rect box, short bullet)
{
#ifdef MAC
	Rect frame;
	PicHandle p;

	p = GetPicture(bullet == BULLET_OPENTRIANGLE ? OPENLEPICT : CLOSEDLEPICT);
	if (!p) { SysBeep(1); return; }

	//frame = (**p).picFrame;
	frame = GetPICTFrame(p);
	MyOffsetRect(&frame, box.left - 1, box.top - 2);
	if (bullet == BULLET_OPENTRIANGLE)
		MyOffsetRect(&frame, 0, 2);
	else
		MyOffsetRect(&frame, 2, 0);
	DrawPicture(p, &frame);
#else
	POINT points[3];

	if (bullet == BULLET_OPENTRIANGLE) {
		points[0] = MakePOINT(box.left - 1, (box.top + box.bottom) / 2 - 1);
		points[1] = MakePOINT(box.right + 1, (box.top + box.bottom) / 2 - 1);
		points[2] = MakePOINT((box.right + box.left) / 2, box.bottom - 1);
		Polygon(currentHDC, points, 3);
	}
	else {
		MyMoveTo(box.left, box.top - 2);
		MyLineTo(box.right - 1, (box.top + box.bottom) / 2);
		MyLineTo(box.left, box.bottom + 1);
		MyLineTo(box.left, box.top - 2);
	}
#endif
}
void Geser(Triangle *T, int deltaX, int deltaY)
/* I.S. T terdefinisi */
/* F.S. T digeser, setiap absisnya sebesar deltaX dan setiap ordinatnya sebesar deltaY */
{
	(*T).P1 = MakePOINT(GetAbsis(GetPointN((*T),0)) + deltaX, GetOrdinat(GetPointN((*T),0)) + deltaY);
	(*T).P2 = MakePOINT(GetAbsis(GetPointN((*T),1)) + deltaX, GetOrdinat(GetPointN((*T),1)) + deltaY);
	(*T).P3 = MakePOINT(GetAbsis(GetPointN((*T),2)) + deltaX, GetOrdinat(GetPointN((*T),2)) + deltaY);
}
void SetPointN(Triangle *T, Point newP, int N)
/* Mengubah nilai komponen Point ke-N dari T */
{
	switch(N){
		case 0: (*T).P1 = MakePOINT(GetAbsis(newP), GetOrdinat(newP)); break;
		case 1: (*T).P2 = MakePOINT(GetAbsis(newP), GetOrdinat(newP)); break;
		case 2: (*T).P3 = MakePOINT(GetAbsis(newP), GetOrdinat(newP)); break;
	}
}
Triangle MakeTRIANGLE (Point P1, Point P2, Point P3)
/* Membentuk sebuah POINT dari komponen-komponennya */
{
	Triangle T;
	T.P1 = MakePOINT(P1.X, P1.Y);
	T.P2 = MakePOINT(P2.X, P2.Y);
	T.P3 = MakePOINT(P3.X, P3.Y);
	return T;
}
Triangle PlusDelta(Triangle T, int deltaX, int deltaY)
/* Mengirim salinan T yang absis dari setiap pointnya adalah Absis(P) + deltaX dan
 * ordinat dari setiap pointnya adalah Ordinat(P) + deltaY */
{
	Triangle newT;
	newT.P1 = MakePOINT(GetAbsis(GetPointN(T,0)) + deltaX, GetOrdinat(GetPointN(T,0)) + deltaY);
	newT.P2 = MakePOINT(GetAbsis(GetPointN(T,1)) + deltaX, GetOrdinat(GetPointN(T,1)) + deltaY);
	newT.P3 = MakePOINT(GetAbsis(GetPointN(T,2)) + deltaX, GetOrdinat(GetPointN(T,2)) + deltaY);
	return newT;
}
Beispiel #7
0
void DrawMapBoundsPoly (CMap* theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings, Boolean erasePolygon)
{
	long numPts = (**MapPolyHdl).pointCount;
	POINT **pointsH = (POINT**)_NewHandle(numPts *sizeof(POINT));
	POINT *pointsPtr = (POINT*)_NewPtr(numPts *sizeof(POINT));
	LongPoint** thisPointsHdl=nil;
	Point pt;
	LongPoint wPt;
	long i;
	Boolean offQuickDrawPlane = false;
	RGBColor saveColor; // JLM ?? wouldn't compile without this
	if(!pointsH || !pointsPtr) {SysBeep(5); return;}
	
	thisPointsHdl = (LongPoint**) (**MapPolyHdl).objectDataHdl;
	for(i = 0; i< numPts;i++)
	{
		wPt = INDEXH(thisPointsHdl,i);
		pt = GetQuickDrawPt(wPt.h,wPt.v,&gRect,&offQuickDrawPlane);
		INDEXH(pointsH,i) = MakePOINT(pt.h,pt.v);
		(pointsPtr)[i] = MakePOINT(pt.h,pt.v);
		// code goes here, make sure this point does not equal previous point JLM
	}
	GetForeColor (&saveColor);		/* save original forecolor */

		if (erasePolygon)
		{
			RgnHandle newClip=0;
			HBRUSH whiteBrush;
			newClip = CreatePolygonRgn((const POINT*)pointsPtr,numPts,ALTERNATE);
			whiteBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
			//err = SelectClipRgn(currentHDC,savedClip);
			FillRgn(currentHDC, newClip, whiteBrush);
			//DeleteObject(newClip);
			DisposeRgn(newClip);
			//SelectClipRgn(currentHDC,0);
		}
		else
		{
			POINT p[2];
			p[0] = INDEXH(pointsH,numPts-1);
			p[1] = INDEXH(pointsH,0);
			RGBForeColor(&colors[BLACK]);
			if(numPts >= 2) 
			{
				Polyline(currentHDC,*pointsH,numPts);
				Polyline(currentHDC,p,2);	// close the polygon
			}
		}

	RGBForeColor (&saveColor);
	DisposeHandle((Handle)pointsH);
	if(pointsPtr) {_DisposePtr((Ptr)pointsPtr); pointsPtr = 0;}
}
Triangle scaleTriangle(Triangle T, float scale)
/* Mengembalikan Triangle yang sudah dikalikan dengan skala */
{
	Triangle newT;
	float x_center = (T.P1.X + T.P2.X + T.P3.X) / 3;
	float y_center = (T.P1.Y + T.P2.Y + T.P3.Y) / 3;
	
	newT.P1 = MakePOINT(x_center + (T.P1.X - x_center) * scale, y_center + (T.P1.Y - y_center) * scale);
	newT.P2 = MakePOINT(x_center + (T.P2.X - x_center) * scale, y_center + (T.P2.Y - y_center) * scale);
	newT.P3 = MakePOINT(x_center + (T.P3.X - x_center) * scale, y_center + (T.P3.Y - y_center) * scale);
	
	return newT;
}
Beispiel #9
0
Points getPoints(int x1, int y1, int x2, int y2) {
	int i,dx,dy,sdx,sdy,dxabs,dyabs,x,y,px,py;
	int counter = 0;
	Point temp;	
	dx=x2-x1;			//Delta x
	dy=y2-y1;			//Delta y
	dxabs=abs(dx);		//Absolute delta
	dyabs=abs(dy);		//Absolute delta
	sdx=(dx>0)?1:-1; //signum function
	sdy=(dy>0)?1:-1; //signum function
	x=dyabs>>1;
	y=dxabs>>1;
	px=x1;
	py=y1;
	Points p = makePoints();
	if (dxabs>=dyabs)
	{
		for(i=0;i<dxabs;i++)
		{
			y+=dyabs;
			if (y>=dxabs)
			{
				y-=dxabs;
				py+=sdy;
			}
			px+=sdx;
			temp = MakePOINT(px,py);
	        p.tabPoint[p.neff]=temp;
			//printf("(%d, %d)\n", p.tabPoint[p.neff].X, p.tabPoint[p.neff].Y);		
			p.neff++;
		}
	}
	else
	{
		for(i=0;i<dyabs;i++)
		{
			x+=dxabs;
			if (x>=dyabs)
			{
				x-=dyabs;
				px+=sdx;
			}
			py+=sdy;
			temp = MakePOINT(px,py);
	        p.tabPoint[p.neff]=temp;
			//printf("(%d, %d)\n", p.tabPoint[p.neff].X, p.tabPoint[p.neff].Y);		
			p.neff++;
		}
	}
	return p;
}
int main(){
	srand(time(NULL));
	stackpoint S;
	spinfotype X;
	int i,j;
	spCreateEmpty(&S);
	printf("spIsEmpty:%x\n",spIsEmpty(S));
	for (i=1;i<=10;i++)
	for (j=1;j<=10;j++){
		X=MakePOINT(i,j);
		printf("pushing ");
		TulisPOINT(X);printf(" to stack\n");
		spPush(&S,X);
	}
	printf("spIsEmpty:%x\n",spIsEmpty(S));
	for (i=1;i<=10;i++)
	for (j=1;j<=10;j++){
		X=MakePOINT(i,j);
		spPop(&S,&X);
		printf("pop:");TulisPOINT(X);printf("\n");
	}
	printf("spIsEmpty:%x\n",spIsEmpty(S));
	for (i=1;i<=5;i++){
		X=MakePOINT(rand(),rand());
		printf("pushing ");
		TulisPOINT(X);printf(" to stack\n");
		spPush(&S,X);
	}
	printf("spIsEmpty:%x\n",spIsEmpty(S));
	for (i=1;i<=5;i++){
		X=MakePOINT(rand(),rand());
		printf("pushing ");
		TulisPOINT(X);printf(" to stack\n");
		spPush(&S,X);
	}
	printf("spIsEmpty:%x\n",spIsEmpty(S));
	for (i=1;i<=10;i++){
		spPop(&S,&X);
		printf("pop:");TulisPOINT(X);printf("\n");
	}
	printf("spIsEmpty:%x\n",spIsEmpty(S));
	return 0;
}
void COMMAND_INFO() {
	int x, y;
	do {
		printf("Enter the coordinate of the cell: ");
		scanf("%d %d", &x, &y);
	} while (!isValidCoordinate(x, y));
	
	Grid *grid = GetGrid(MakePOINT(x, y));
	Type type = GetType(*grid);
	Player *gridOwner = GetOwner(*grid);
	Unit *unit = GetUnit(*grid);

	printf("== Cell Info ==\n");
	if (type == Normal) {
		printf("Normal\n");
	} else if (type == Tower) {
		printf("Tower\n");
	} else if (type == Castle) {
		printf("Castle\n");
	} else if (type == Village) {
		printf("Village\n");
	}

	printf("Owned by Player %d\n", GetPlayerIndex(*gridOwner));

	if (unit) {
		Player *unitOwner = GetPlayerFromColor(GetUnitColor(*unit));
		char unitClassName[11];
		UnitClassName(GetUnitClass(*unit), unitClassName);

		printf("== Unit Info ==\n");
		printf("%s\n", unitClassName);
		printf("Owned by Player %d\n", GetPlayerIndex(*unitOwner));
		printf("Health %d/%d | ATK %d\n", 
			GetHealth(*unit), 
			GetMaximumHealth(*unit), 
			GetAttack(*unit)
		);
	}

	printf("\n");
}
Beispiel #12
0
POINT NextY (POINT P) {
	return MakePOINT(GetAbsis(P),GetOrdinat(P)+1);
} // Ordinat ditambah 1
Beispiel #13
0
void DrawMapPoly (CMap* theMap, PolyObjectHdl MapPolyHdl, DrawSpecRecPtr drawSettings)
{
	RGBColor	saveColor;
	drawSettings -> bClosed = IsPolyClosed (MapPolyHdl);
#ifdef MAC
	long		PointCount;

	//drawSettings -> bClosed = IsPolyClosed (MapPolyHdl);

	GetForeColor (&saveColor);		/* save original forecolor */

	if (drawSettings -> bClosed)
	{
		if (drawSettings -> mode == kPictMode)
		{
			DrawSectPoly (theMap, MapPolyHdl, drawSettings);	/* changed 11/21/95 due to postscript errors */
//			DrawNoSectPoly (theMap, MapPolyHdl, drawSettings);	/* changed back on 3/28/96
		}
		else
		{
			//PointCount = GetPolyPointCount (MapPolyHdl);
			//if (PointCount > 7000)
			//{
			//	/* draw polygon interior without any frame */
			//	drawSettings -> frameCode = kNoFrameCode;
			//	DrawNoSectPoly (theMap, MapPolyHdl, drawSettings);
			//
				/* then draw polygon outline without using poly-routines */
			//	drawSettings -> frameCode = kPaintFrameCode;
			//	drawSettings -> fillCode = kNoFillCode;
			//	DrawNoSectPoly (theMap, MapPolyHdl, drawSettings);
			//}
			//else
				DrawNoSectPoly (theMap, MapPolyHdl, drawSettings);
		}
	}
	else	/* hollow polygon, no fill of any kind */
	{
		DrawNoSectPoly (theMap, MapPolyHdl, drawSettings);
	}

	RGBForeColor (&saveColor);

	return;
#else
	long numPts = (**MapPolyHdl).pointCount;
	POINT **pointsH = (POINT**)_NewHandle(numPts *sizeof(POINT));
	LongPoint** thisPointsHdl=nil;
	Point pt;
	LongPoint wPt;
	long i, esiCode;
	long penWidth = 2, halfPenWidth = 0;
	Boolean bDrawBlackAndWhite = (sharedPrinting && settings.printMode != COLORMODE);
	Boolean offQuickDrawPlane = false, drawingESILayer = false;
	if(!pointsH) {SysBeep(5); return;}
	
	thisPointsHdl = (LongPoint**) (**MapPolyHdl).objectDataHdl;
	GetObjectESICode ((ObjectRecHdl) MapPolyHdl,&esiCode); 
	if (esiCode>0) 	// -500 is the default
	{
		//halfPenWidth = penWidth/2;
		PenStyle(BLACK,penWidth);
		drawingESILayer = true;
	}
	for(i = 0; i< numPts;i++)
	{
		wPt = INDEXH(thisPointsHdl,i);
		//pt.h = SameDifferenceX(wPt.h);
		//pt.v = (gRect.bottom + gRect.top) - SameDifferenceY(wPt.v);
		pt = GetQuickDrawPt(wPt.h,wPt.v,&gRect,&offQuickDrawPlane);
		//pt.h += drawSettings -> offsetDx;
		//pt.v += drawSettings -> offsetDy;
		INDEXH(pointsH,i) = MakePOINT(pt.h-halfPenWidth,pt.v-halfPenWidth);
		// code goes here, make sure this point does not equal previous point JLM
	}
	GetForeColor (&saveColor);		/* save original forecolor */

	//Our_PmForeColor (bDrawBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);//JLM
	// make sure the blackandwhite bitmaps come out right
	Our_PmForeColor (bDrawBlackAndWhite || gDrawBitmapInBlackAndWhite ? kBlackColorInd : drawSettings -> foreColorInd);//JLM
	if (drawSettings -> fillCode == kNoFillCode && drawSettings->backColorInd == kWaterColorInd) 
		Our_PmForeColor (drawSettings -> foreColorInd);
	else
	{
		if(bDrawBlackAndWhite) 
		{
			//SetPenPat(UPSTRIPES);
			// we want solid outline and a patterned inside
			FillPat(UPSTRIPES);
			PenStyle(BLACK,1);
		}
	}

	//if(numPts > 2) Polygon(currentHDC,*pointsH,numPts);
	// 6/11/03 PC wasn't recognizing the flag for not filling a land polygon
	if (drawSettings -> bClosed)
	{
		if(numPts > 2) Polygon(currentHDC,*pointsH,numPts);
	}
	else
	{
		//POINT p[2];
		//p[0] = INDEXH(pointsH,numPts-1);
		//p[1] = INDEXH(pointsH,0);
		//RGBForeColor(&colors[BLACK]);
		if(numPts >= 2) 
		{
			Polyline(currentHDC,*pointsH,numPts);
			//if (!drawingESILayer)
				//Polyline(currentHDC,p,2);	// close the polygon
		}
	}

	if(bDrawBlackAndWhite) SetPenPat(BLACK);
	
	RGBForeColor (&saveColor);
	DisposeHandle((Handle)pointsH);

#endif
}
int main(){
	int i,h,DX,DY;
	float sudut;
	POINT ptest,p1,p2;
	srand(time(NULL));
	ptest=MakePOINT(rand(),rand());
	TulisPOINT(ptest);
	SetAbsis(&ptest,rand());
	TulisPOINT(ptest);
	SetOrdinat(&ptest,rand());
	TulisPOINT(ptest);
	BacaPOINT(&ptest);
	TulisPOINT(ptest);

//cek operator relasional
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand(),rand());
		p2=MakePOINT(rand(),rand());
		TulisPOINT(p1);
		printf("==");
		TulisPOINT(p2);
		printf("=");
		h=EQ(p1,p2);
		printf("%x\n",h);
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand(),rand());
		p2=p1;
		TulisPOINT(p1);
		printf("==");
		TulisPOINT(p2);
		printf("=");
		h=EQ(p1,p2);
		printf("%x\n",h);
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand(),rand());
		p2=MakePOINT(rand(),rand());
		TulisPOINT(p1);
		printf("!=");
		TulisPOINT(p2);
		printf("=");
		h=NEQ(p1,p2);
		printf("%x\n",h);
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand(),rand());
		p2=p1;
		TulisPOINT(p1);
		printf("!=");
		TulisPOINT(p2);
		printf("=");
		h=NEQ(p1,p2);
		printf("%x\n",h);
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand(),rand());
		TulisPOINT(p1);
		printf("is Origin");
		printf("=");
		h=IsOrigin(p1);
		printf("%x\n",h);
	}
	p1=MakePOINT(0,0);
	TulisPOINT(p1);
	printf("is Origin");
	printf("=");
	h=IsOrigin(p1);
	printf("%x\n",h);
	printf("\n\ncek\n");
	p1=MakePOINT(0,rand());
	TulisPOINT(p1);
	printf("is Origin");
	printf("=");
	h=IsOrigin(p1);
	printf("%x\n",h);
	printf("\n\ncek\n");
	p1=MakePOINT(rand(),0);
	TulisPOINT(p1);
	printf("is Origin");
	printf("=");
	h=IsOrigin(p1);
	printf("%x\n",h);
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand(),rand());
		TulisPOINT(p1);
		printf("is On SbX");
		printf("=");
		h=IsOnSbX(p1);
		printf("%x\n",h);
	}
	p1=MakePOINT(0,0);
	TulisPOINT(p1);
	printf("is SbX");
	printf("=");
	h=IsOnSbX(p1);
	printf("%x\n",h);
	p1=MakePOINT(0,rand());
	TulisPOINT(p1);
	printf("is SbX");
	printf("=");
	h=IsOnSbX(p1);
	printf("%x\n",h);
	p1=MakePOINT(rand(),0);
	TulisPOINT(p1);
	printf("is SbX");
	printf("=");
	h=IsOnSbX(p1);
	printf("%x\n",h);
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand(),rand());
		TulisPOINT(p1);
		printf("is On SbY");
		printf("=");
		h=IsOnSbY(p1);
		printf("%x\n",h);
	}
	p1=MakePOINT(0,0);
	TulisPOINT(p1);
	printf("is SbY");
	printf("=");
	h=IsOnSbY(p1);
	printf("%x\n",h);
	p1=MakePOINT(0,rand());
	TulisPOINT(p1);
	printf("is SbY");
	printf("=");
	h=IsOnSbY(p1);
	printf("%x\n",h);
	p1=MakePOINT(rand(),0);
	TulisPOINT(p1);
	printf("is SbY");
	printf("=");
	h=IsOnSbY(p1);
	printf("%x\n",h);
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand()-rand(),rand()-rand());
		printf("kuadran ");
		TulisPOINT(p1);
		printf("=");
		h=Kuadran(p1);
		printf("%d\n",h);
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand(),rand());
		printf("NextX ");
		TulisPOINT(p1);
		printf("=");
		TulisPOINT(NextX(p1));
		printf("\n");
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand(),rand());
		printf("NextY ");
		TulisPOINT(p1);
		printf("=");
		TulisPOINT(NextY(p1));
		printf("\n");
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand()-rand(),rand()-rand());
		TulisPOINT(p1);
		DX=rand()%10;
		DY=rand()%10;
		printf(" + (%d,%d) =",DX,DY);
		TulisPOINT(PlusDelta(p1,DX,DY));
		printf("\n");
		TulisPOINT(p1);
		printf(" + (%d,%d)g =",DX,DY);
		Geser(&p1,DX,DY);
		TulisPOINT(p1);
		printf("\n");
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT(rand()-rand(),rand()-rand());
		printf("MirrorOf(");
		TulisPOINT(p1);
		printf(",1,0) =");
		TulisPOINT(MirrorOf(p1,1,0));
		printf("\n");
	}
	for (i=0;i<14;i++){
		p1=MakePOINT(rand()-rand(),rand()-rand());
		printf("MirrorOf(");
		TulisPOINT(p1);
		printf(",0,1) =");
		TulisPOINT(MirrorOf(p1,0,1));
		printf("\n");
	}
	for (i=0;i<14;i++){
		p1=MakePOINT(rand()-rand(),rand()-rand());
		printf("MirrorOf(");
		TulisPOINT(p1);
		printf(",1,1) =");
		TulisPOINT(MirrorOf(p1,1,1));
		printf("\n");
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT((rand()-rand())%10,(rand()-rand())%10);
		printf("Jarak0(");
		TulisPOINT(p1);
		printf(") = %f",Jarak0(p1));
		printf("\n");
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT((rand()-rand())%10,(rand()-rand())%10);
		p2=MakePOINT((rand()-rand())%10,(rand()-rand())%10);
		printf("Panjang(");
		TulisPOINT(p1);
		printf(",");
		TulisPOINT(p2);
		printf(") = %f",Panjang(p1,p2));
		printf("\n");
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT((rand()-rand())%10,(rand()-rand())%10);
		TulisPOINT(p1);
		printf("digeser ke Sb-X menjadi ");
		GeserKeSbX(&p1);
		TulisPOINT(p1);
		printf("\n");
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT((rand()-rand())%10,(rand()-rand())%10);
		TulisPOINT(p1);
		printf("digeser ke Sb-Y menjadi ");
		GeserKeSbY(&p1);
		TulisPOINT(p1);
		printf("\n");
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT((rand()-rand())%10,(rand()-rand())%10);
		TulisPOINT(p1);
		printf("dicerminkan dengan Sb-X menjadi ");
		Mirror(&p1,1,0);
		TulisPOINT(p1);
		printf("\n");
	}
	for (i=0;i<14;i++){
		p1=MakePOINT((rand()-rand())%10,(rand()-rand())%10);
		TulisPOINT(p1);
		printf("dicerminkan dengan Sb-Y menjadi ");
		Mirror(&p1,0,1);
		TulisPOINT(p1);
		printf("\n");
	}
	for (i=0;i<14;i++){
		p1=MakePOINT((rand()-rand())%10,(rand()-rand())%10);
		TulisPOINT(p1);
		printf("dicerminkan dengan (0,0) menjadi ");
		Mirror(&p1,1,1);
		TulisPOINT(p1);
		printf("\n");
	}
	printf("\n\ncek\n");
	for (i=0;i<14;i++){
		p1=MakePOINT((rand()-rand())%10,(rand()-rand())%10);
		sudut=(float) (rand()%360);
		
		TulisPOINT(p1);
		printf("diputar %0.0f derajat menjadi ",sudut);
		Putar(&p1,sudut);
		TulisPOINT(p1);
		printf("\n");
	}
	printf("M_PI=%f\n",M_PI);
	return 0;
}
Beispiel #15
0
/* KELOMPOK OPERASI LAIN TERHADAP TYPE */
POINT NextX (POINT P) {
	return MakePOINT(GetAbsis(P)+1,GetOrdinat(P));
} // Absis ditambah 1
POINT PlusDelta(POINT P, int deltaX, int deltaY)
/* Mengirim salinan P yang absisnya adalah Absis(P) + deltaX dan ordinatnya adalah Ordinat(P) + deltaY */
{
    return MakePOINT(Absis(P) + deltaX, Ordinat(P) + deltaY);
}
POINT NextY(POINT P)
/* Mengirim salinan P dengan ordinat ditambah satu */
{
    return MakePOINT(Absis(P), Ordinat(P) + 1);
}
/* *** KELOMPOK OPERASI LAIN TERHADAP TYPE *** */
POINT NextX(POINT P)
/* Mengirim salinan P dengan absis ditambah satu */
{
    return MakePOINT(Absis(P) + 1, Ordinat(P));
}
Beispiel #19
0
POINT PlusDelta (POINT P, float deltaX, float deltaY) {
	return MakePOINT(GetAbsis(P)+deltaX,GetOrdinat(P)+deltaY);
} // P=[Absis(P)+deltaX,Ordinat(P)+deltaY]