# I have n points (x ,y coordinates known) of two parallel lines (not perfect straight ) want to draw lines from first boundary points to second boundary with proper slope . Also want to find min & max distance between the lines.

4 views (last 30 days)
vaishali on 10 Jun 2014
Commented: vaishali on 10 Jun 2014
BOUN1=[ 179 248 179 249 180 250 180 251 180 252 180 253 180 254 180 255 179 256 179 257 179 258 178 259 179 260 180 261 179 262 179 263 179 264 178 265 178 266 178 267 178 268 179 269 180 270 182 271 182 272 182 273 181 274 181 275 181 276 181 277 181 278 181 279 181 280 181 281 182 282 182 283 182 284 181 285 179 286 179 287 179 288 179 289 181 290 181 291 181 292 181 293] AND BOUN2=[ 306 248 305 249 306 250 306 251 306 252 306 253 307 254 306 255 306 256 306 257 306 258 307 259 308 260 308 261 308 262 308 263 309 264 308 265 308 266 309 267 309 268 309 269 309 270 310 271 310 272 310 273 310 274 310 275 310 276 310 277 310 278 310 279 310 280 310 281 310 282 310 283 311 284 310 285 310 286 308 287 309 288 310 289 311 290 311 291 312 292 312 293]
Tried the below code but it draws several lines from min distance point.I want to draw a line (from each POINTS of BOUN2)with proper slope on BOUN1.
if true
% code
end[xy,distance,t_a] = distance2curve(BOUN1,BOUN2,'linear');
plot(BOUN1(:,1),BOUN1(:,2),'k-o',BOUN2(:,1),BOUN2(:,2),'r*')
hold on
plot(xy(:,1),xy(:,2),'g*')
line([BOUN2(:,1),xy(:,1)]',[BOUN2(:,2),xy(:,2)]','color',[0 0 1])
axis equal
if true
% code
end

George Papazafeiropoulos on 10 Jun 2014
BOUN1=[ 191 220 189 221 188 222 186 223 186 224 185 225 185 226 185 227 185 228 186 229 187 230 187 231 187 232 187 233 187 234 188 235 188 236 188 237 189 238 189 239 188 240 188 241 187 242 187 243 186 244 186 245 185 246 185 247 185 248 185 249 185 250 184 251 185 252 185 253 187 254 188 255 193 256 192 257 192 258 191 259 190 260 190 261 190 262 190 263 189 264 189 265 189 266 190 267 191 268 191 269 189 270 189 271 189 272 190 273 192 274 193 275 192 276 192 277 192 278 193 279 194 280 194 281]';
BOUN2=[ 302 220 302 221 303 222 302 223 302 224 303 225 303 226 304 227 304 228 305 229 305 230 304 231 304 232 304 233 304 234 305 235 304 236 305 237 306 238 306 239 306 240 305 241 305 242 305 243 307 244 307 245 307 246 307 247 306 248 305 249 306 250 307 251 306 252 306 253 306 254 306 255 307 256 306 257 307 258 307 259 308 260 308 261 309 262 309 263 309 264 308 265 309 266 310 267 309 268 310 269 309 270 310 271 311 272 311 273 311 274 311 275 310 276 310 277 310 278 310 279 310 280 310 281]';
BOUN1=reshape(BOUN1,2,[])';
BOUN2=reshape(BOUN2,2,[])';
X1=[BOUN1(:,1),BOUN2(:,1)]';
Y1=[BOUN1(:,2),BOUN2(:,2)]';
line(X1,Y1);
axis equal
vaishali on 10 Jun 2014
This code draws straight lines between two boundaries.To find accurate distance between boundaries diagonal coordinates also want to consider.so according to inclination of two boundaries drawn lines must have proper slope. if true % code endBOUN1=reshape(BOUN1',2,[])';
BOUN2=reshape(BOUN2',2,[])';
X1=[BOUN1(:,1),BOUN2(:,1)]';
Y1=[BOUN1(:,2),BOUN2(:,2)]'; line(X1,Y1); axis equal
if true
% code
end