# Question About Rotating Quad

**URL:** <https://discourse.processing.org/t/question-about-rotating-quad/1423>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [July 1, 2018, 11:16pm UTC](https://discourse.processing.org/t/question-about-rotating-quad/1423 "2018-07-01T23:16:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![QuazArxx](https://avatars.discourse-cdn.com/v4/letter/q/7ba0ec/32.png) [@QuazArxx](https://discourse.processing.org/u/QuazArxx)\
**Post date:** [July 1, 2018, 11:16pm UTC](https://discourse.processing.org/t/question-about-rotating-quad/1423/1 "2018-07-01T23:16:09Z")

</div>

So the title may not be clear enough but i’m trying to make the Galactic Empire emblem from Star Wars. in the very middle circle there are trapezoids coming out. I made the first top one but is there a formula or a function to make the other trapezoids AS WELL AS rotate them with each one made?

Currently i’m using the quad function to make the trapezoid. I already have to figure out how i’m going to shrink the whole thing together but i’m hoping i could get an actual not too detailed answer using simple beginner functions if it’s possible.

Thanks!

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 2, 2018, 12:14am UTC](https://discourse.processing.org/t/question-about-rotating-quad/1423/2 "2018-07-02T00:14:31Z")

</div>

Check this [tutorial](https://processing.org/tutorials/transform2d/) about 2D transforms

Post some code if you are stuck.

Kf

---

<div class="post-metadata">

**Author:** ![QuazArxx](https://avatars.discourse-cdn.com/v4/letter/q/7ba0ec/32.png) [@QuazArxx](https://discourse.processing.org/u/QuazArxx)\
**Post date:** [July 2, 2018, 1:15am UTC](https://discourse.processing.org/t/question-about-rotating-quad/1423/3 "2018-07-02T01:15:28Z")

</div>

Well I was asking if there was a function or formula to use to move and translate. I had already looked at that but that’s not helping me with moving and rotation a quad() shape as well as repeating so they’re spaced evenly and rotate at the same time.

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 2, 2018, 3:24am UTC](https://discourse.processing.org/t/question-about-rotating-quad/1423/4 "2018-07-02T03:24:42Z")

</div>

Yes, R/T depends on quad definition. It is really hard to picture your quads based on the description you provided. It is better if you provide a sketch or image of what you want to do. For any shape, you can always rotate and translate them. Choosing the reference point for translation and the pivot point for rotation depends on the shape and based on selection, you can make your life easier or more difficult.

Kf

---

<div class="post-metadata">

**Author:** ![behreajj](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@behreajj](https://discourse.processing.org/u/behreajj)\
**Post date:** [July 2, 2018, 12:05pm UTC](https://discourse.processing.org/t/question-about-rotating-quad/1423/5 "2018-07-02T12:05:12Z")

</div>

To create patterns such as those found in the Galactic Empire logo, you could try code like

```auto
size(512, 512);
smooth(8);
background(255);
fill(0);
noStroke();

int count = 6;

// Translation
float centerX = width * 0.5;
float centerY = height * 0.5;

// Rotation
float rotation = HALF_PI;
float arcLength = PI / 8.0;
float halfArcLength = arcLength * 0.5;
float iToTheta = TWO_PI / float(count);

// Scale
float shortEdge = min(width, height);
float outerRadius = shortEdge * 0.45;
float innerRadius = shortEdge * 0.2;

for (int i = 0; i < count; ++i) {
  float angle = rotation + i * iToTheta;
  float t0 = angle - halfArcLength;
  float t1 = angle + halfArcLength;

  float ct0 = cos(t0);
  float st0 = sin(t0);

  float ct1 = cos(t1);
  float st1 = sin(t1);

  float p0x = centerX + ct0 * innerRadius;
  float p0y = centerY + st0 * innerRadius;

  float p1x = centerX + ct1 * innerRadius;
  float p1y = centerY + st1 * innerRadius;

  float p2x = centerX + ct1 * outerRadius;
  float p2y = centerY + st1 * outerRadius;

  float p3x = centerX + ct0 * outerRadius;
  float p3y = centerY + st0 * outerRadius;

  quad(p0x, p0y,
    p1x, p1y,
    p2x, p2y,
    p3x, p3y);
}

```

You may also find the [arc](https://processing.org/reference/arc_.html) function useful. The following is added at the end of the code above.

```auto
noFill();
stroke(255.0, 0.0, 0.0);
strokeWeight(20.0);
strokeCap(SQUARE);
float radius = shortEdge * 0.7;
float arcLength2 = PI / 4.0;
float halfArcLength2 = arcLength2 * 0.5;
for (int i = 0; i < count; ++i) {
  float theta = rotation + i * iToTheta;
  float t0 = theta - halfArcLength2;
  float t1 = theta + halfArcLength2;
  arc(centerX, centerY, radius, radius, t0, t1, OPEN);
}

```

The final image produced by this code looks like this:

 ![000](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/1X/b72f437a73f310dc607442406c2ce5140eb11702.png)

---

<div class="post-metadata">

**Author:** ![MxFxM](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@MxFxM](https://discourse.processing.org/u/MxFxM)\
**Post date:** [July 2, 2018, 1:15pm UTC](https://discourse.processing.org/t/question-about-rotating-quad/1423/6 "2018-07-02T13:15:51Z")

</div>

Have you tried pushMatrix() and popMatrix() to reset the canvas after each object you try to rotate/move?
