Message Boards Message Boards

0
|
1870 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

ColorFunction use in Graphics

I have what I thought was a simple matter. I have a square rectangle that I want to transpose. To make obvious the fact that the square is now on its "side" and not its "bottom" one needs to have the color variegated or otherwise such that it is obvious the square has rotated 90 degrees. I tried A LOT of things but, here is the last one that did not work

Graphics[{LightGreen,Texture[sample swatch],Parallelogram[{0, 0}, IdentityMatrix[2]]}, Axes -> True, PlotRange -> {{-3, 3}, {-3, 3}}]
POSTED BY: Roger J Brown
5 Replies

POSTED BY: Michael Rogers
Posted 11 months ago

maybe this is usefull, using polygon you could add colors to the square, that way when you rotate it the change is notorious

Graphics[{Rotate[
   Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}, 
    VertexColors -> {Red, Red, Blue, Blue}], 45 Degree]}
 , Axes -> True, PlotRange -> {{-3, 3}, {-3, 3}}]

enter image description here

POSTED BY: Legibus Motus

Ah, yes, I should have said why that does not work at this stage. This is a matrix algebra classroom example so that is the reason for having a Parallelogram in the present case is so there are vertex points to transform. My workaround is to use a non-square rectangle, but that is sub-optimal in this case for pedagogical reasons.

I should also mention, this exercise, fully elaborated, needs to end up in 3D with a "house" made from placing a pyramid on a cube and rotating it using RotationTransform to complete the illustration. Following the Documentation and mixing PolyhedronData with GeometricTransform to do this is not straightforward and I am struggling with that at present.

POSTED BY: Roger J Brown
Posted 11 months ago

For 3D maybe you can experiment with the CSG functions.

pyramid = Pyramid[{{0, 0, 2}, {2, 0, 2}, {2, 2, 2}, {0, 2, 2}, {1, 1, 4}}];
cube = Cube[{1, 1, 1}, 2];

house = CSGRegion["Union", {pyramid, cube}]

Graphics3D[house, Boxed -> False]

Coloring to match your needs may be a bit challenging. I don't know how to do it.

POSTED BY: Rohit Namjoshi

Slick. In this case once I get the shape the color does not matter. But also in this case using the Wolfram built in functions defeats the classroom matrix transform example.

POSTED BY: Roger J Brown
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract