![]() |
【转帖】odgeboundblock2d
odgeboundblock2d
odgeboundblock2d hello and greetings to all the team, i'm trying to use class odgeboundblock2d in order to know if a picked point is inside a parallelogram defined through a base point and two vectors. i use the following code in a test odgevector2d vec2dir1(10,0); odgevector2d vec2dir2(0,10); odgepoint2d pt2dbase(0,0); odgepoint2d pt2dpick(5,5); odgeboundblock2d block2d(pt2dbase, vec2dir1, vec2dir2); bool bisbox=block2d.isbox(); bool bcontains=block2d.contains(pt2dpick); i think that what i'm doing with this code is defining a parallelogram with side one beginning at point (0,0) and ending at point (10,0), side two beginning at point (10,0) and ending at point (10,10), side three at point (10,10) and ending at point (0,10) and side four beginning at point (0,10) and ending at point (0,0). if so, function isbox() should return true, but it returns false, and function contains() should return true , but it also returns false. which could be the reason? is there a better method to know if a point is inside a region not aligned with cartesian axis? which dwgdirect class should i use to define this kind of region? odgeboundblock2d block2d(pt2dbase, vec2dir1, vec2dir2); block2d.settobox(true); bool bisbox=block2d.isbox(); bool bcontains=block2d.contains(pt2dpick); hello again, i've used function settobox(true) as you suggested, and it works in the case i set out before, where the parallelogram was indeed a rectangle, aligned with cartesian axis. but i've tried to construct a non-aligned parallelogram, using the following example. odgevector2d vec2dir1(5,3); odgevector2d vec2dir2(-3,2); odgepoint2d pt2dbase(3,0); odgepoint2d pt2dpick(1,1); odgeboundblock2d block2d(pt2dbase, vec2dir1, vec2dir2); block2d.settobox(true); bool bcontains=block2d.contains(pt2dpick); i'm supposing that the parallelogram is constructed as follows: from point (3,0) it comes to point (8,3), then it comes to point (5,5) and ends at point (0,2), i'm also assuming that coordinates of both vectors are refered to base point. if this is correct, point (1,1) should not be contained by the parallelogran, but it is. thanks in advance. odgeboundbox2d::contains() does not work correctly for parallelogram due to bug in dd. sergey slezkin |
所有的时间均为北京时间。 现在的时间是 01:20 AM. |