Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
13 views
1.develop A Program To Draw A Line Using Bresenham's Line Drawing Technique
Uploaded by
patrick Park
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save 1.1.1 For Later
Download
Save
Save 1.1.1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
13 views
1.develop A Program To Draw A Line Using Bresenham's Line Drawing Technique
Uploaded by
patrick Park
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save 1.1.1 For Later
Carousel Previous
Carousel Next
Save
Save 1.1.1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 1
Search
Fullscreen
1.
Develop a program to draw a line using Bresenham’s line drawing technique
import turtle/def bresenham_line(x1, y1, x2, y2)://dx = abs(x2 - x1)/dy = abs(y2 - y1)
/x_step = 1 if x1 < x2 else -1//error = 2 * dy – dx/line_points = []/x, y = x1, y1
for _ in range(dx + 1):/line_points.append((x, y))/if error > 0:/y += y_step//error -= 2 * dx
error += 2 * dy/x += x_step/return line_points/turtle.setup(500, 500)/turtle.speed(0)
x1, y1 = 100, 100/x2, y2 = 400, 300/line_points = bresenham_line(x1, y1, x2, y2)/turtle.penup()
turtle.goto(x1, y1)/turtle.pendown()/for x, y in line_points:/turtle.goto(x, y)turtle.exitonclick()
2.Develop a program to demonstrate basic geometric operations on the 2D object
import turtle/import math/screen = turtle.Screen()/screen.bgcolor("white")/t = turtle.Turtle()
t.speed(1)/t.pensize(2)/def draw_rectangle(x, y, width, height, color):/t.penup()//t.goto(x, y)
t.pendown()/t.color(color)/for _ in range(2):/t.forward(width)/t.left(90)/t.forward(height)/t.left(90)
def draw_circle(x, y, radius, color):/t.penup()/t.goto(x, y - radius)/t.pendown()/t.color(color)/t.circle(radius)
def translate(x, y, dx, dy):/ t.penup()/t.goto(x + dx, y + dy)/t.pendown()/def rotate(x, y, angle):/ t.penup()
t.goto(x, y) /t.setheading(angle)/t.pendown()/def scale(x, y, sx, sy):/ t.penup()/t.goto(x * sx, y * sy) /t.pendown()
draw_rectangle(-200, 0, 100, 50, "blue")/translate(-200, 0, 200, 0)/draw_rectangle(0, 0, 100, 50, "blue")
rotate(0, 0, 45)/draw_rectangle(0, 0, 100, 50, "blue")/scale(0, 0, 2, 2)/draw_rectangle(0, 0, 100, 50, "blue")
draw_circle(100, 100, 50, "red")/translate(100, 100, 200, 0)/draw_circle(300, 100, 50, "red")/rotate(300, 100, 45)
draw_circle(300, 100, 50, "red")/scale(300, 100, 2, 2)/draw_circle(600, 200, 50, "red")/turtle.done()
3.Develop a program to demonstrate basic geometric operations on the 3D object
from vpython import canvas, box, cylinder, vector, color, rate/
scene = canvas(width=800, height=600, background=color.white)/
def draw_cuboid(pos, length, width, height, color):/cuboid = box(pos=vector(*pos),
length=length, width=width, height=height, color=color)/return cuboid
def draw_cylinder(pos, radius, height, color):cyl = cylinder(pos=vector(*pos),
radius=radius, height=height, color=color)/return cyl/def translate(obj, dx, dy, dz):
obj.pos += vector(dx, dy, dz)/def rotate(obj, angle, axis):
obj.rotate(angle=angle, axis=vector(*axis))/def scale(obj, sx, sy, sz):
obj.size = vector(obj.size.x * sx, obj.size.y * sy, obj.size.z * sz)
cuboid = draw_cuboid((-2, 0, 0), 2, 2, 2, color.blue)translate(cuboid, 4, 0, 0)/rotate(cuboid, angle=45, axis=(0, 1, 0))
scale(cuboid, 1.5, 1.5, 1.5)/cylinder = draw_cylinder((2, 2, 0), 1, 10, color.red)/translate(cylinder, 0, -2, 0)
/rotate(cylinder, angle=30, axis=(1, 0, 0))/scale(cylinder, 1.5, 1.5, 1.5)/while True:/rate(30)
4.Develop a program to demonstrate 2D transformation on basic objects
import cv2/import numpy as np/canvas_width = 500/canvas_height = 500
/canvas = np.ones((canvas_height, canvas_width, 3), dtype=np.uint8) * 255
/obj_points = np.array([[100, 100], [200, 100], [200, 200], [100, 200]], dtype=np.int32)
/translation_matrix = np.float32([[1, 0, 100], [0, 1, 50]])/rotation_matrix = cv2.getRotationMatrix2D((150, 150), 45, 1)
scaling_matrix = np.float32([[1.5, 0, 0], [0, 1.5, 0]])
translated_obj = np.array([np.dot(translation_matrix, [x, y, 1])[:2] for x, y in obj_points], dtype=np.int32)
rotated_obj = np.array([np.dot(rotation_matrix, [x, y, 1])[:2] for x, y in translated_obj], dtype=np.int32)
scaled_obj = np.array([np.dot(scaling_matrix, [x, y, 1])[:2] for x, y in rotated_obj], dtype=np.int32)
cv2.polylines(canvas, [obj_points], True, (0, 0, 0), 2)/cv2.polylines(canvas, [translated_obj], True, (0, 255, 0), 2)
cv2.polylines(canvas, [rotated_obj], True, (255, 0, 0), 2)/cv2.polylines(canvas, [scaled_obj], True, (0, 0, 255), 2)
cv2.imshow("2D Transformations", canvas)/cv2.waitKey(0)/cv2.destroyAllWindows()
5.Develop a program to demonstrate 3D transformation on 3D objects
import pygame.from pygame.locals import */from OpenGL.GL import *
from OpenGL.GLU import */import numpy as np/pygame.init()/display_width = 800/display_height = 600
display = pygame.display.set_mode((display_width, display_height), DOUBLEBUF | OPENGL)
pygame.display.set_caption("3D Transformations")/glClearColor(0.0, 0.0, 0.0, 1.0)/glEnable(GL_DEPTH_TEST)
/glMatrixMode(GL_PROJECTION)/gluPerspective(45, (display_width / display_height), 0.1, 50.0)
glMatrixMode(GL_MODELVIEW)/vertices = np.array([[-1, -1, -1],/[1, -1, -1],/[1, 1, -1],/[-1, 1, -1],
/[-1, -1, 1],/[1, -1, 1],/[1, 1, 1],[-1, 1, 1]], /dtype=np.float32)/edges = np.array([[0, 1], [1, 2], [2, 3], [3, 0],
/[4, 5], [5, 6], [6, 7], [7, 4],/[0, 4], [1, 5], [2, 6], [3, 7]], dtype=np.uint32)/translation_matrix = np.eye(4, dtype=np.float32)
/translation_matrix[3, :3] = [0, 0, -5]/rotation_matrix = np.eye(4, dtype=np.float32)
/scaling_matrix = np.eye(4, dtype=np.float32)/scaling_matrix[0, 0] = 1.5/scaling_matrix[1, 1] = 1.5
scaling_matrix[2, 2] = 1.5/running = True/angle = 0/while running:/for event in pygame.event.get():
if event.type == pygame.QUIT:/running = False/glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()/glMultMatrixf(translation_matrix)/glRotatef(angle, 1, 1, 0)/glMultMatrixf(rotation_matrix)
glMultMatrixf(scaling_matrix)/glBegin(GL_LINES)/for edge in edges:
for vertex in edge:/glVertex3fv(vertices[vertex])/glEnd()/angle += 1/pygame.display.flip()/pygame.quit()
You might also like
Solution Manual For Fractal Geometry Mathematical Foundations and Applications, 3nd (Falconer)
PDF
100% (2)
Solution Manual For Fractal Geometry Mathematical Foundations and Applications, 3nd (Falconer)
95 pages
' Maths - Stage 8 - 01 - 5RP - AFP - tcm143-639975
PDF
100% (2)
' Maths - Stage 8 - 01 - 5RP - AFP - tcm143-639975
16 pages
Paper Strip Game
PDF
No ratings yet
Paper Strip Game
6 pages
Lesson Plan in Mathematics 5: Area of A Circle
PDF
100% (10)
Lesson Plan in Mathematics 5: Area of A Circle
3 pages
CG Lab - Manual
PDF
No ratings yet
CG Lab - Manual
15 pages
Computer Graphics and Image Processing Laboratory Manual
PDF
No ratings yet
Computer Graphics and Image Processing Laboratory Manual
27 pages
CG Lab Manual
PDF
No ratings yet
CG Lab Manual
37 pages
All Pro
PDF
No ratings yet
All Pro
4 pages
CG_Lab_Programs
PDF
No ratings yet
CG_Lab_Programs
6 pages
File: /home/srinu/desktop/g.txt Page 1 of 6
PDF
No ratings yet
File: /home/srinu/desktop/g.txt Page 1 of 6
6 pages
CG&IP Lab Manual
PDF
No ratings yet
CG&IP Lab Manual
59 pages
21CSL66 CG Lab Manual Search Creators
PDF
100% (1)
21CSL66 CG Lab Manual Search Creators
52 pages
CG Program Explanation
PDF
No ratings yet
CG Program Explanation
23 pages
P 3
PDF
No ratings yet
P 3
1 page
Ilovepdf Merged
PDF
No ratings yet
Ilovepdf Merged
14 pages
QW
PDF
No ratings yet
QW
6 pages
Cglab Pgms
PDF
No ratings yet
Cglab Pgms
13 pages
21CSL66 CG Lab Manual
PDF
No ratings yet
21CSL66 CG Lab Manual
49 pages
PROG 6 (1) Karthik
PDF
No ratings yet
PROG 6 (1) Karthik
4 pages
Lab Manual CG and Image Processing 21 Scheme
PDF
No ratings yet
Lab Manual CG and Image Processing 21 Scheme
27 pages
I017 CG Lab5-1
PDF
No ratings yet
I017 CG Lab5-1
12 pages
Computer Graphics Lab Manual For VTU
PDF
No ratings yet
Computer Graphics Lab Manual For VTU
23 pages
CGLABMANUALNEW
PDF
No ratings yet
CGLABMANUALNEW
11 pages
CG Lab
PDF
No ratings yet
CG Lab
9 pages
Practical Computer Graphics
PDF
No ratings yet
Practical Computer Graphics
28 pages
CGA Prac
PDF
No ratings yet
CGA Prac
30 pages
Output
PDF
No ratings yet
Output
1 page
cg manual
PDF
No ratings yet
cg manual
13 pages
2 ND
PDF
No ratings yet
2 ND
1 page
Advanced Level Module 2
PDF
No ratings yet
Advanced Level Module 2
22 pages
Python Programs - Part 1 - Curve Stitching
PDF
No ratings yet
Python Programs - Part 1 - Curve Stitching
30 pages
CG Assignment
PDF
No ratings yet
CG Assignment
13 pages
LAB FILE(CG)
PDF
No ratings yet
LAB FILE(CG)
9 pages
exp9[1]
PDF
No ratings yet
exp9[1]
8 pages
CV Lab 10 Manual
PDF
No ratings yet
CV Lab 10 Manual
5 pages
Lab Record
PDF
No ratings yet
Lab Record
30 pages
P 5
PDF
No ratings yet
P 5
2 pages
COMP1021 HKUST (Examples)
PDF
0% (1)
COMP1021 HKUST (Examples)
8 pages
QuickRef VPYTHON
PDF
No ratings yet
QuickRef VPYTHON
1 page
Advanced Level Module 1
PDF
No ratings yet
Advanced Level Module 1
19 pages
Advanced Level Modules
PDF
No ratings yet
Advanced Level Modules
41 pages
CGA TILL LAB 9 (1) Removed
PDF
No ratings yet
CGA TILL LAB 9 (1) Removed
18 pages
nea 3d-2d
PDF
No ratings yet
nea 3d-2d
2 pages
Computer Graphics-1
PDF
No ratings yet
Computer Graphics-1
43 pages
Cg Practical File
PDF
No ratings yet
Cg Practical File
21 pages
CGM Lab2
PDF
No ratings yet
CGM Lab2
8 pages
Python-Tutle Help Doc
PDF
No ratings yet
Python-Tutle Help Doc
39 pages
Sol Mod 2
PDF
No ratings yet
Sol Mod 2
58 pages
Lecture2supp PictureLanguage
PDF
No ratings yet
Lecture2supp PictureLanguage
48 pages
Game Programming
PDF
No ratings yet
Game Programming
35 pages
KJSCE/IT/LY/SEMVIII/ROB/2019-20: (Autonomous College Affiliated To University of Mumbai)
PDF
No ratings yet
KJSCE/IT/LY/SEMVIII/ROB/2019-20: (Autonomous College Affiliated To University of Mumbai)
9 pages
CG 2024 Journal
PDF
No ratings yet
CG 2024 Journal
6 pages
MathAdventures Solutions
PDF
No ratings yet
MathAdventures Solutions
27 pages
CG printout
PDF
No ratings yet
CG printout
10 pages
CGI Manual @vtuupdates Com
PDF
No ratings yet
CGI Manual @vtuupdates Com
37 pages
Cs Project
PDF
No ratings yet
Cs Project
8 pages
Paint Material
PDF
No ratings yet
Paint Material
44 pages
Week 10
PDF
No ratings yet
Week 10
10 pages
0200346 Dicky Larson
PDF
No ratings yet
0200346 Dicky Larson
60 pages
exp-10 safik
PDF
No ratings yet
exp-10 safik
10 pages
Profound Python Data Science
From Everand
Profound Python Data Science
Onder Teker
No ratings yet
No Ph.D. Game Design With Three.js
From Everand
No Ph.D. Game Design With Three.js
Nikiforos Kontopoulos
No ratings yet
Line Drawing Algorithm: Mastering Techniques for Precision Image Rendering
From Everand
Line Drawing Algorithm: Mastering Techniques for Precision Image Rendering
Fouad Sabry
No ratings yet
Yukti circular
PDF
No ratings yet
Yukti circular
1 page
Deep Learning
PDF
No ratings yet
Deep Learning
26 pages
CNS Module 2
PDF
No ratings yet
CNS Module 2
19 pages
Cryptography m2 Super Imp
PDF
No ratings yet
Cryptography m2 Super Imp
7 pages
Deep Learning Module-04 Search Creators
PDF
No ratings yet
Deep Learning Module-04 Search Creators
17 pages
21CS733 IMP Questions
PDF
0% (1)
21CS733 IMP Questions
2 pages
Deep Learning Module-03 Search Creators
PDF
No ratings yet
Deep Learning Module-03 Search Creators
20 pages
Deep Learning Module-01 Search Creators
PDF
No ratings yet
Deep Learning Module-01 Search Creators
17 pages
Miniproject Draft
PDF
No ratings yet
Miniproject Draft
10 pages
CN QB-Final
PDF
No ratings yet
CN QB-Final
2 pages
Questions - Intermediate Division
PDF
100% (1)
Questions - Intermediate Division
17 pages
06-07 Ladder Slides Down The Wall - Differential Calculus Review
PDF
No ratings yet
06-07 Ladder Slides Down The Wall - Differential Calculus Review
4 pages
Kinematics Assignment
PDF
No ratings yet
Kinematics Assignment
17 pages
Lecture 4 - Simple Harmonic Motion
PDF
No ratings yet
Lecture 4 - Simple Harmonic Motion
14 pages
Isometric Projections
PDF
No ratings yet
Isometric Projections
20 pages
Class 7 IMO: Answer The Questions
PDF
No ratings yet
Class 7 IMO: Answer The Questions
3 pages
76 Loci and Construction
PDF
0% (1)
76 Loci and Construction
11 pages
Geometry For Programmers Meap V11 Meap 11 Oleksandr Kaleniuk pdf download
PDF
100% (1)
Geometry For Programmers Meap V11 Meap 11 Oleksandr Kaleniuk pdf download
91 pages
Syllabus Mathematics
PDF
100% (1)
Syllabus Mathematics
96 pages
Journal #2 Chapter 11 - Athenian Mathematics I: The Classical Problems
PDF
No ratings yet
Journal #2 Chapter 11 - Athenian Mathematics I: The Classical Problems
43 pages
Convex Polygon
PDF
No ratings yet
Convex Polygon
19 pages
Rotational Dynamics
PDF
No ratings yet
Rotational Dynamics
91 pages
Trig Missing Angle
PDF
No ratings yet
Trig Missing Angle
16 pages
Maths G 11 & 12 Unit 6
PDF
No ratings yet
Maths G 11 & 12 Unit 6
8 pages
Fractal Sound - Research Folder
PDF
No ratings yet
Fractal Sound - Research Folder
43 pages
Name - AP Calculus BC Date - Approximation Project
PDF
No ratings yet
Name - AP Calculus BC Date - Approximation Project
4 pages
Diagnostic Test in Mathematics 6
PDF
No ratings yet
Diagnostic Test in Mathematics 6
8 pages
CA Lesson 3 Relative Velocity
PDF
No ratings yet
CA Lesson 3 Relative Velocity
22 pages
Acceleration in Mechanisms
PDF
100% (2)
Acceleration in Mechanisms
22 pages
NAME: .CLASS: ADM NO: ... SCHOOL: : Evaluate (3 Marks)
PDF
No ratings yet
NAME: .CLASS: ADM NO: ... SCHOOL: : Evaluate (3 Marks)
10 pages
2015 H2 C1 Promo Questions
PDF
No ratings yet
2015 H2 C1 Promo Questions
6 pages
Cherryfield Montessori School End of Second Term Examination (July, 2022) Mathematics Jhs 1 Section A
PDF
No ratings yet
Cherryfield Montessori School End of Second Term Examination (July, 2022) Mathematics Jhs 1 Section A
8 pages
Concepts_Formulae sheet-GEOMETRY-(2024-25)
PDF
No ratings yet
Concepts_Formulae sheet-GEOMETRY-(2024-25)
36 pages
Mass Point
PDF
No ratings yet
Mass Point
5 pages
G7 Math Q3-Week 5 - Polygons
PDF
No ratings yet
G7 Math Q3-Week 5 - Polygons
15 pages
Penang 2013 STPM Trial Papers For Mathematics T Term 2
PDF
No ratings yet
Penang 2013 STPM Trial Papers For Mathematics T Term 2
10 pages
Science Fair Manual 2019
PDF
No ratings yet
Science Fair Manual 2019
11 pages