home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.graphics
- Path: sparky!uunet!spool.mu.edu!uwm.edu!ux1.cso.uiuc.edu!bert.eecs.uic.edu!artn
- From: artn@bert.eecs.uic.edu (Stephan Meyers)
- Subject: HELP: Hexagon tiling problem
- Message-ID: <1992Dec15.003038.14130@bert.eecs.uic.edu>
- Organization: University of Illinois at Chicago
- Date: Tue, 15 Dec 1992 00:30:38 GMT
- Lines: 29
-
- I don't think the answer to this is in the FAQ, and I browsed
- Graphic Gems III (I can't find the lab's copy of I and II) but I doubt the
- answer is there, either.
-
- Given a plane tiled with hexagons and a point (x,y) on the plane,
- how do I find the point corresponding to the center of the hexagon that the
- given point lies in.
-
- Although my use for this function is a little more esoteric, it could
- be used to do a "hexagonal pixellation," which would be funky looking.
- I've tried solving this problem a few different ways. The most do-able
- is to fmod() the whole space into a rectangle two units high and three wide,
- and then to partition x into four regions: the first region corresponds to
- a whole hex, the third goes either up or down, and for the second and fourth
- you check if the point lies above, below, or between the two angled segments.
- This seems somewhat inelegant, however, and I suspect there's a more direct
- way to do it.
- Since I know the slopes of the lines connecting the centers, I tried
- using y=mx+b, solving for b, then rounding b off to the nearest unit, for
- both angles (sqrt(3) and -sqrt(3)), and then finding the intersection.
- However, I ended up with rhombuses.
- Suggestions? Is this in one of the Gems? Help!
-
- Stephan
- --
- --
- Stephan Meyers | artn@uicbert.eecs.uic.edu
- (Art)^n Laboratories, inventors of the Stealth Negative PHSCologram
- (312) 567-3762
-