• No results found

LEC_16_3D line clipping.pdf

N/A
N/A
Protected

Academic year: 2020

Share "LEC_16_3D line clipping.pdf"

Copied!
19
0
0

Loading.... (view fulltext now)

Full text

(1)

Cohen Sutherland

Cyrus and Beck

(2)

Clipping window

(X

max

, Y

max

, Z

max

)

(X

min

, Y

min

, Z

min

)

X

Y Z

(3)

Six Regions

If both the region codes of the endpoints are zero then the line can be trivially accepted

Else if Logical AND of these regions codes is non zero then it can be trivially rejected

(4)

Region codes

Bit position Bit Value calculation

1 TOP bit value =1if (Zmax-Z) is – ve and if +ve, bit value =0 2 BOTTOM bit value =1if (Z-Zmin) is – ve and if +,ve bit value =0 3 RIGHT bit value =1if (Ymax-Y) is – ve and if +ve, bit value =0 4 LEFT bit value =1 if (Y-Ymin) is – ve and if +ve, bit value =0 5 FRONT bit value =1 if (Xmax-X) is – ve and if +ve, bit value =0 6 REAR bit value =1if (X-Xmin) is – ve and if +ve, bit value =0

T

op

B

ottom

R

ight

L

eft

F

ront

R

ear

Nihar Ranjan Roy

p0(1,-1,-1) to p1(0.5,3,1)

P0=010100 P1=001000

(2,2,2)

(0,0,0)

X

(5)

Six planes(Surfaces)

(6)

Calculations of ‘t’

P(t)=p

1

+(p

2

-p

1

)t

t=(P(t)-p

1

)/(p

2

-p

1

)

t

top

=(Z

max

-Z

0

)/(Z

1

-Z

0

)

t

bottom

=(Z

min

-Z

0

)/(Z

1

-Z

0

)

t

right

=(Y

max

-Y

0

)/(Y

1

-Y

0

)

t

left

=(Y

min

-Y

0

)/(Y

1

-Y

0

)

t

front

=(X

max

-X

0

)/(X

1

-X

0

)

t

back

=(X

min

-X

0

)/(X

1

-X

0

)

Nihar Ranjan Roy

X

(7)

problem

A line from p0(1,-1,-1) to p1(0.5,3,1) is to be clipped against the clipping volume defined by a cube with two diagonally opposite

corners at (0,0,0) & (2,2,2). Use the Cohen

(8)

Solution

P0010100 P1001000

P0&P1=000000so the line cannot be trivially accepted or rejected

Looking at the outcode of P0 we find that it must be clipped against the bottom boundary

tbottom=

The intersection with the bottom plane is X(t)=x0+(x1-x0)t=1+(0.5-1)1/2=0.75

Y(t)=y0+(y1-y0)t=-1+(3+1)1/2=1 & Z=zmin=0

2 1 0 1 0 min    z z z z

Nihar Ranjan Roy

(9)

The out code for the new point p`(0.75,1,0) is 000000. Hence this end does not require clipping.

P1 clip it with respect to right plane Y=ymax=2

tright= =2+1/(3+1)=3/4

P(3/4)=(0.6 ,2,0.5)

The visible portion of the line segment is (0.75,1,0) & (0.6,2,0.5)

0 1

0 max

y y

y y

(10)

 Consider a convex region R  A boundary point f on the

convex region R

 An outer normal for one of its

boundaries n

 We can distinguish in which

region a point lie by looking at the value of the dot product

n.[p(t)-f]

Nihar Ranjan Roy 10

Cyrus and Beck Algorithm

x y

n

(11)

Potential Leaving (PL) and Entering (PE)

 ni.[p(t)-f] <0 then the vector p(t)-f is

pointed away from the interior of R Lets call it (PL potentially leaving)

 ni.[p(t)-f] =0 then p(t)-f is pointed

parallel to the plane containing f and perpendicular to normal.

 ni.[p(t)-f] >0 then p(t)-f is pointed

towards the interior of R, lets call it PE

At the point of intersection

with boundary the condition is

(12)

PE vs PL

 PE(potentially entering) intersection:

 If moving from P0 to P1 causes us to cross an edge to enter

the edge's inside half plane;

 PL(potentially leaving) intersection:

 If moving from P0 to P1 causes us to leave the edge's inside

half plane.

Ni • P0P1 > 0 PL Ni • P0P1 < 0 PE

(13)

n.[p(t)-f]=0

n.[p1+(p2-p1)t-f]=0

This relation can be applied to each boundary plane or edge of the window to get the intersection points. Thus the general form

equation can be written as

ni.[p1+(p2-p1)t-f]=0

Where i is the edge number

The same equation can also be written as

ni.[p1-f]+ni.[p2-p1]t=0

Let D=p -p //direction of line

(14)

Thus ni.wi+(ni.D)t=0

Where D ≠ 0 and i=1,2,3,..

We must select the proper value for t using following tips

1. If t is outside the range 0<=t<=1 then it can be ignored

2. The line can intersect the convex window at most two points, but using the above

equation there can be multiple values of t in the range 0<=t<=1. we have to choose the largest lower limit and smallest upper limit.

3. If Di.ni>0 then equation gives lower limit (PL) value for t and if Di.ni<0 then it gives

upper limit (PE) for value of t.

Nihar Ranjan Roy 14

D n

w n t

i i i i

. .

(15)

Cyrus- Beck approach for 3D line clipping

 Cyrus beck line clipping technique for 2D can directly be

applicable to 3D line clipping with little modifications

 Clipping window is replaced by clipping volume

 Instead of convex polygon we deal with convex polyhedron

for the window

 Clipping edges are replaced by clip plane

(16)

Nihar Ranjan Roy 16

Algorithm

1. Read the two endpoints of the line segment say p0 and p1. 2. Read vertex coordinates of the clipping window/volume 3. Calculate D=p1-p0.

4. Assign boundary point with each particular edge/surface 5. Find outer normal for the corresponding edge/surface 6. Calculate D.n and W=p1-f.

7. If D.n>0

1. tL=-W.n/D.n 2. else

3. tU=-W.n/D.n 4. Endif

8. Repeat step 4 to 7 for each edge/surface of the clipping window 9. Find the maximum lower limit and minimun upper limit

(17)

problem

A line from p1(1,-1,-1) to p2(0.5,3,1) is to be clipped against the clipping volume defined by a cube with two diagonally opposite

(18)

solution

Outer Normals for each edge/boundary

Point f on boundary Top nt=(0,0,1) 2 2 2

Bottom 0 0 -1 0 0 0

Right 0 1 0 2 2 2

Left 0 -1 0 0 0 0

Front 1 0 0 2 2 2

Rear -1 0 0 0 0 0

D n w n p p n f p n t i i i i i i . . ) .( ) .( 1 2

1  

  

Nihar Ranjan Roy

(2,2,2)

(0,0,0)

X

(19)

Plane N f Wi=(P1-f) n.W= n.(p1-f)

n.D Type t

Top 0 0 1 2 2 2 (-1 -3 -3) -3 2 PL 𝟑

𝟐=1.5

Bottom 0 0 -1 0 0 0 (1 -1 -1) 1 -2 PE 𝟏

𝟐=0.5

Right 0 1 0 2 2 2 (-1 -3 -3) -3 4 PL 𝟑

𝟒=0.75

Left 0 -1 0 0 0 0 (1 -1 -1) 1 -4 PE 𝟏

𝟒=0.25

Front 1 0 0 2 2 2 (-1 -3 -3) -1 -0.5 PE -2

Rear -1 0 0 0 0 0 (1 -1 -1) -1 0.5 PL 2.0

tPE=max(0.25, 0.5,-2)=0.50

D=p2-p1 =[0.5 3 1]-[1 -1 -1]=[-0.5 4 2] W1=(p1-f)=[1 -1 -1]-[2 2 2]=[-1 -3 -3]

If n.D>0 then PL else PE n D

w n p p n f p n t i i i i i i . . ) .( ) .( 1 2

1  

  

References

Related documents

All treatment protocols recognize a step- by-step approach to treatment with different drugs used in early SE (stage I), established SE (stage II), refractory (stage III)

Utilize a dog model in anestrus to measure plasma progesterone concentrations in the bitch after single administration of vaginally (Crinone ® ) and oral (Prometrium ® )

The key segments in the mattress industry in India are; Natural latex foam, Memory foam, PU foam, Inner spring and Rubberized coir.. Natural Latex mattresses are

Indeed, the Web survey of 411 risk managers— conducted by the Flaspöhler Research Group, in partnership with National Underwriter—found that 45.8 percent are “very

Control of working capital - An understanding of the methods a business might use to stock, debtor and creditor improve the control of its working capital. Links here should be

Chief Financial Officer.. 2) Revenue from non-LFL stores and the acquired Boardman Bikes business amounted to £2.9m in FY15.. Order &amp; Collect represents items that are not in

The Bolton (1991) model captures the importance of comparative payoffs, but does not explain non-minimal effort at high wages, as one should never wish to decrease one’s relative

The SAA does recognise, however, that a system based on discrete capital valuations would allow charging regimes and/or bands to be overlaid in a manner which would allow these to