# Combining Modulus

## Recommended Posts

Help!

I have some geometry distributed on a line by modulus of its ids.
Well 2 modulus distributions which is where my issue is.

Without using arrays (I will be eventually processing a large amount of geo), I want to rotate each "node" up the vertical line a progressive amount (say 10 degrees for for example) by combining the modulus calcs somehow. And I am pretty stuck!

(This is a particle simulation so these lines are the result of this. So you can't just run over prims and rotate them in vertical order or anything so simple. It is simply setting up the initial directions, thus the need to combine the moduli).

Edited by Jim M
##### Share on other sites

Ok, so "combining" is not a very good word to use when it comes to math concepts, as it can be extremely arbitrary.

For ease of discussion, I am going to call what you are looking to do a function.  It will have inputs and an output.  You are looking to input the moduli, but a modulus is a function which is applied to a pair of numbers to yield the remainder if they were divided.  This does not really make sense as an input, which I think is the reason you are struggling.  I think getting a handle on what you want your inputs to actually be and your output to be would probably go a long way towards helping find the correct answer.  You mention that you want to use the two moduli to increment the rotation of the initial velocity.  What would that look like in your mind?  Are you looking to transition between two vectors based on the moduli?

##### Share on other sites

Thanks for your reply Adam. Wise words indeed. When I posted this I was quite unclear with myself about method and outcome. I kind of lazily assumed I could somehow mathematically combine two modulus into an automatically incrementing function. I got myself all turned around because I am chaining sop solvers and it is really hard to conceptually grasp exactly what is happening at any point in time. So some of the concepts get entangled quite easily. It is actually even hard to explain what is happening in a concise yet meaningful way.

+I made this example trying to distill the idea into something readable, but in hindsight it just reflects my initial lack of focus. I am writing an HDA in lots of vex and some of it is a bit ...let's say 'organic' in its organisation...

The solution was obviously...

if A or B increment++

But in my set up it's lots of nested loops and arrays for parent child structures.

Fortunately all solved.

Thanks!

Edited by Jim M
##### Share on other sites

Well, I'm glad that things are solved.  I'm still curious about the project though.

What you have listed there works incredibly well actually

```int A == @ptnum%23;
int B == @ptnum%16;
int i=0;
while(True) {
i += (A==0 || B==0);
if(i>100000000 || @ptnum == npoints(0)-1) {
break;
}
}```

If it isn't apparent, if statement in the while loop is solely in existence to end the loop if things get out of hand to keep it from being infinite and locking up the computer.  Always a good idea with while(true).

Edited by Jim M

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×