AM, PDMS PML

AM, PDMS LINE OBJECT

agape93 2021. 2. 17. 21:21

LINE OBJECT

 

!pos = array()
!line = object line()
!dir = object direction()

var sctnlist collect all sctn for ce

do !s index !sctnlist
	-- 시작점과 끝점을 저장
	!poss = poss of $!sctnlist[$!s] wrt /*
	!pose = pose of $!sctnlist[$!s] wrt /*
	!pos.append(!poss)
	!pos.append(!pose)
	
	!linetemp = object line(!poss, !pose)
	!linedir = !linetemp.direction()
    
	-- aid number, line type ( 1:solid, 2:dashed, 3:dotted ), color 지정
	!linetemp.draw(101,1,7)
    
	-- DIR 비교
	if !dir.unset() then
		!dir = !linedir
	else
		-- 두개의 방향이 같으면 1, 직각이면 0, 반대면 -1
		!dirchk = !dir.dot(!linedir)
		handle any
		endhandle
		-- 다음 sctn 방향과 비교하기 위해 저장
		!dir = !linedir
	endif
    
	-- LINE 합치기
	if !line.unset() then
		!line = !linetemp
	else
		!line = !line.union(!linetemp)
		handle any
		endhandle
	endif
    
	-- 연장선상에 있는지 확인
	if !s.gt(1) then
		-- LINE 선상에서 POS와 가장 가까운 위치
		!nearposs = !line.near(!poss)
		if !poss.eq(!nearposs) then
			$p >>> poss ok
		endif
		
		!nearpose= !line.near(!pose)
		if !pose.eq(!nearpose) then
			$p >>> pose ok
		endif
	endif
enddo

-- POS 중 큰값과 작은값 사이의 거리
!posmax = !pos[!pos.sortedindices().last()]
!posmin = !pos[!pos.sortedindices().first()]
!dist = !posmax.distance(!posmin)

참고 : https://section.cafe.naver.com/