We are about to switch to a new forum software. Until then we have removed the registration on this forum.

- All Categories 25.7K
- Announcements & Guidelines 13
- Common Questions 30
- Using Processing 22.1K
- Programming Questions 12.2K
- Questions about Code 6.4K
- How To... 4.2K
- Hello Processing 72
- GLSL / Shaders 292
- Library Questions 4K
- Hardware, Integration & Other Languages 2.7K
- Kinect 668
- Arduino 1K
- Raspberry PI 188
- Questions about Modes 2K
- Android Mode 1.3K
- JavaScript Mode 413
- Python Mode 205
- Questions about Tools 100
- Espanol 5
- Developing Processing 548
- Create & Announce Libraries 211
- Create & Announce Modes 19
- Create & Announce Tools 29
- Summer of Code 2018 93
- Rails Girls Summer of Code 2017 3
- Summer of Code 2017 49
- Summer of Code 2016 4
- Summer of Code 2015 40
- Summer of Code 2014 22
- p5.js 1.6K
- p5.js Programming Questions 947
- p5.js Library Questions 315
- p5.js Development Questions 31
- General 1.4K
- Events & Opportunities 289
- General Discussion 365

after a previous question which was answered, translate is cumulative.

i have reached that point again in open processing that i reached years ago, translate is designed wrong.

if i use translate (4,0,0) in a loop it will increment x by 4 8 12 etc. this is fine to translate(-4,0,0) to undo how this function works.

but if i use a complex equation such as

```
translate(0,0,20*cos(radians(posx)*mod)*sin(radians(posy)*mod) );
```

this could be impossible to undo the translate.

so my real question is, why the hell is translate cumulative, this really is a stupid way to design a function ?

## Answers

https://Processing.org/reference/resetMatrix_.html

no its not

because it makes good sense

no it isn't

If you translate with

`translate(x, y, z);`

you can reverse it with

`translate(-x, -y, -z);`

The translate, rotate, and scale transformations are cumulative so you can combine them to create complex transformations which would be difficult to do in one operation.

so how do i reverse a complex equation if the equation cannot be reversed.

example: this equation can be reversed but if i use more complex equation its impossible to reverse without a matrixreset or pop. also using matrixreset or pop in multiple calls to other sketches adds to the confusion.

this example should have times in it but it deletes the times when posting. [fixed]

this is why translate is designed wrong, you cant undo all equations?

another example try reversing this one then ?

as for complexity of other functions scale, rotate etc its not exactly difficult to do a +1 loop with maths sin etc. but its difficult to undo these functions.

If you translate with

you can reverse it with

In that case, your x is

`posk * tan(mod) * 3`

, your y is`posj * sin(posk)`

, and your z is... well, you get the idea.So what about if i use a random how can i undo a random or what about an external device changing values ?

Unless i store all the random outputs of an equation to undo translate then i cant undo translate?

I cant reset or pop a matrix back to a random point without saving the random output, a matrix has no definition or label so, if i popmatrix back to XYZ random from different sketches then the problems start ?

Tracking multiple objects in 3 dimensions isnt exactly easy to undo ?

This is why i stopped using processing a couple of years ago, was hoping a solution or alternative was available?

Im no expert on this but online it says open gl 3.0 has depricated push pop matrix, android supports open gl 3.0!!!

Translate without matrix ????

i think you need to show us what you are trying to do and why translate isn't working for you.

(because at the moment it just sounds like you are complaining about addition and having to use local variables.)

you should post code as code, otherwise it takes two *s as the delimiters for a italic section. i've fixed a couple of the problem sentences above.