java - move object towards or away centre until collision -
i working in javafx trying centre objects around point without overlapping. trying make word cloud programme.
at first trying place them in spiral if collision occurred (i have method detecting collisions in class)
if (collisiondetected){ text.translatexproperty().asobject().setvalue((double)80); }
but couldn't work out how set path in spiral
so thought generate rand.int x y values , move towards centre point until collision detected , place object , move onto next object in list. not sure how set path , increment until collision detected. or better start middle , decide rand.int within 360 degrees , create path bounds of scene , increment along until collisiondetected = false
as in
integer randproperty = rand.nextint(0, 360); while(collisiondetected){ path path = new path(); moveto moveto = new moveto(); moveto.setx(randproperty); moveto.sety(randproperty); path.getelements().add(moveto);
i dont know how move across path until collisiondetected = false.
here diagrams linked imgur give visual representation of mean.
to summarize, trying place objects close centre point without having them intersect. can check if intersection has occurred not sure how move text objects area there no intersection. pictures linked imgur visual representation.
thanks
Comments
Post a Comment