Hello all (I hope I'm not doing anything wrong after first posting) ... < / P>
I am trying to generate 3 sets 2l randomly 3 sets of convex polygon so that each side of each polygon l predefined lines of one of If someone knows how to do this (without the help of computational geometry package like CGAL or Shapley, without the help or without), then it would be great. I 2l angle (direction of each line, and direction for each row + pi parallel sides). For each polygon, I want to select 3 to 2l angles randomly from this list, in order to be sorted in ascending order, so that to ensure that no angle PE is no different than before, although the angle is able to define a polygon, after that I am unable to ensure that I am producing a polygon and convex and only the sides Which I have chosen, my code currently looks like this: The first obstacle is the sum of the angles of a convex polygon 180 * (N -2) degrees, where second obligation for Gi two lines, you have two options for your angle: You must choose Green Angle The criteria for your selection are not very clear in your statement, so I can not believe that there is a mistake or not. To select a good angle, I think that the simplest thing to do is to consider the directional vector for each line. Calculate So this leads us to our second hurdle. Looking forward to the side vector and I think the second hurdle is enough, we will not need it first (but still good to know about common sense). What to do Here's what I will do for you: So now you have a list of direction vectors, which are parallel to your lines. This list creates convex polygon Next your polygon will be formed if you need help on this, then tell me!
Generate DRF (L, N, W, H): "" In the Exx Plane, Generate polygon. "" L = [] polygon = [] while lane (l)
N is the number of sides of your convex polygon [].
u to the vector with the direction of your last line (pointing to direction). Compute
v , a direction vector of the new line. If
(u ^ v) & gt; 0 ,
v is not oriented correctly, so you want to move
-v . Otherwise, if
(u ^ v) & lt; 0 ,
v is correctly oriented Description:
u ^ v = ux * vy -uy * vx
u_next direction, we have the
u ^ u_next & lt; Keeping in mind
u ; 0 .
u0 Calculate as if
u0.x> 0 . Start with the list of direction vector with
listDV Note: if choose
u.x = 0 , then
u such as
u.y & gt; 0 .
listDV.last ^ list.dV.first <0 ) {Choose the Random Line, Direction Vector
u like < Code> listDV.last ^ u & lt; 0 }
listDV .
No comments:
Post a Comment