is there a way in Cinema 4D to make wind blow in a direction, but not drag in objects at the other side of the fan?
For example, this is what i have now:
A --> A |W=> B --> B (A,B moves thru the fan in direction of wind)
And this is what I want to archieve:
A |W=> B --> B (A remains stationary, B moves)
Thanks for help
In the Wind-object's settings, go to Falloff > Form and set it to Linear. The Wind-objects appeareance has changed now.
From the mid-point to the arrows end-point, the falloff will take place. At the end of the arrow (i.e. where the arrow's cone is), the Wind-object will not have any influence any more.
I don't have access to Cinema atm so i can't confirm this but i belive wind has a falloff you can set to get what you want.
Related
I've been wanting to build a 3D engine starting from scratch as a coding challenge with the end objective of implementing it on a fantasy console.
The best (i.e. most simple?) way I found was raytracing/raycasting. I haven't found much by looking online for raycasting algorithms, only finding point-in-polygon problems (which only tell me whether a ray intersects a polygon or not, not quite my interest since I wouldn't have info about the first intersection nor I'd have the intersection points).
The only solution I could think of is brute forcing the ray by moving it at small intervals and every time check whether that point is occupied by something or not (which would require having filled shapes and wouldn't let me have 2D shapes since they would never be rendered, although none of those is a problem). Still, it looks way too complex performance-wisely.
As far as I know, most of those problems are solved using linear algebra, but I'm not quite as competent as to build up a solution on my own. Does this problem have a practical solution?
EDIT: I just found an algebric solution in 2D which could maybe be expanded in 3D. The idea is:
For each edge, check whether one of the two vertices are in the field of view (i.e. if O is the origin of every ray and P is the vertex, you have to check first that the point is inside the far point of sight, and then whether the angle with the forward vector is less than the angle of vision). If at least one of the two vertices is inside the field of view, add them to an array E.
If we have an array R of rays to shoot and an array of arrays I of info about hit points, we can loop for each ray in R and for each edge in E and then store f(ray, edge) in I, where f is a function that gives us info on whether the ray and the edge collided and where they did.
f uses basic linear algebra: both the ray and the edge are, for all purposes, two segments. Two segments are just parts of two lines. Let's say that if the edge has vertices A and B (AB is the vector that goes from A to B) and if the far point is called P (OP is the vector that goes from O to P). We can create two lines, r and s, defined by A + ηAB and O + λOP. After we do a check to see whether r and s are parallel (check if the absolute value of the dot product of AB and OP is equal to the norm of AB times the norm of OP), it's trivial to get the values for η and λ.
Now, if η < 0 OR η > 1 we have that the two segments are not colliding.
After we've done this for every ray and every edge, we compare every element in each array i in I to see which one had the lowest λ. The lowest λ carries the first collision and hence the data to show on screen.
Everything here is linear algebra, though I fear that it might still be computationally heavy, since there's a lot going on, and it's still only 2D.
I made an OCaml program which draws on a Graphics window the representation of a given l-system using his definition,his commands interpretation and iteration.
The drawing is made using Turtle graphics(the turtle can draw a line,move to a given point and turn for a given angle).
The problem I have is that all the lines have the same size(and this is how it needs to be) and when I draw an L-system if i don't give the right line size the drawing goes out of graphics window as you can see on that picture.
I know I can move the drawing on the left but I always start drawing from the center of the window.What I need help for is how to set the right line size for a given sequence of cammands for example:
I have that list of instructions below :
ACAABAABABACACAACACACACAACAABABACAABAABABACACAACACACACAACAABABACAABAABABACACAACACACACAACAABABACAABAABABACACAACACACACAACAABA.
where A means: Draw a line of "X" size
B : turn π/2
C: turn -π/2.
How can I find the best value for X (size of the line) in order to have a drawing that stays on the graphics window.
The only solution I've found is to start from a given value (Example X=20) and try to draw the l-system with this value, if it goes out then try again with X/2 until it works !
Does anybody have a better idea?
You could do some analysis of the L-system to determine its range, and scale appropriately. However, this is not much different than just drawing it with an arbitrary size (say, 1) seeing how big it is, and scaling (once) to fit the screen (not just X/2 until works). For example, if you draw it with scale=1 and it is 40 units in size, and your screen is 400 units, you know you can draw with scale=10 and still fit. You can also use this first pass to determine XY offset so you can center it.
My idea is to make one pass to evaluate sizes of your labyrinth. Let (W: int) be your width variable. When painter moves West you decrement W and when your painter moves East you incerement W. If m1 is maximal possible value of W and m2 is minimal value (maybe, < 0) of W during process then total width of you diagram is padding + linewidth * (m1-m2)
For example: let's painter initially looks to East.
AAAAABABAAAAAABABA
i.e.
<<<<<.
>.>>>>
During process W will change this way:
AAAAABABAAAAA A B A BA
01234555543210-1-1-1-10
Robot makes 5 steps to East, moves up, and moves 6 steps on West, moves down and returns to start location. In this case m1 = 5 and m2 = -1 and you need canvas of size 5+(-1) multiply line width.
My maths skills are terrible so I don't even know where to start with this. This is for a hobby project written in C#.
To keep things simple, let's say I need to operate on all of the pixels positioned inside an ellipse. How would I get an array of the valid pixel locations inside the ellipse that I need to work with?
For that task i would recommend taking a look at bresenhams filled circle Algorithm.
If you scale the y achsis you can use it to draw ellipses, too.
Bresenham algorithms work by using only integer arithmetic, which makes them fast(est)
This works only for axe-parallel ellipses
In an ellipse the sum of the distance between a point in the ellipse and both foci is twice the major axis so:
PF1 + PF2 = 2a
Where P is the point, F1 and F2 the foci and a the semi major axis.
If the sum is less then 2a the point will be inside the ellispe.
Wikipedia
I have read dozens of questions here on SO (and not only) regarding arkanoid collision detection, namely, moving circle collision against a stationery rectangle, but all of them ask how to detect a collision or how to detect which side of the rectangle the ball hits. My question is a bit different - it concerns the calculation of the new speed direction in case when the ball hits the angle of the rectangle.
For simplicity's sake let's assume that Vx >= 0 and Vy <= 0, that is, the ball is coming from the below from the left upward and rightward and also suppose I know it's gonna hit the lower side of the rectangle. The green arrow shows the approximate direction of the ball and the blue dot shows the first point on the line containing the lower side of the rectangle that the ball hits. If that point lies strictly within the lower side of the rectangle then all is trivial - just change Vy to -Vy. However when that point lies outside the lower side it means that the first point of the rectangle that the ball will touch is going to be its lower-left corner, in which case I don't think that changing the Vy to -Vy is correct. I think that the new velocity angle must be dependent on the distance of the blue point to the corner. Also I think that not only Vy but also Vx must change (preserving, possibly, the length of the V vector).
So, how do we calculate the new Vx and Vy when we hit an angle? If you know any good links that address this question I'd be delighted to know them. Also note that I am more interested in the absolute physical model of this rather than easy-to-code optimized approximations. You can assume there is no rotation involved. Thank you very much in advance
You know how to bounce off a horizontal wall. Do you know how to bounce off a wall that is at some other angle?
When the circle hits the wall, it makes contact at a single point. That single point is all the circle "knows" about the wall; the location of that point gives you enough information to calculate the new V. When the circle hits the corner, it makes contact at a single point (i.e. the corner) so it bounces just as if it hit a wall at that point.
Is that enough to go on, or would you like some math? (And if so, how comfortable are you with vector algebra?)
A simpliciation that is often made when modelling rock blocks in rock mechanics is to assume that the corner of the rectangle has a small radius. The calculation is then one of two curved surfaces contacting. This approach tends to give more consistent behaviour than modelling corners as right angles an so is preferred where consistent results are needed.
I know this is more high school math(wow been a long time since I was there) but I am trying to solve this programatically so I am reaching out to the collective knowledge of stackoverflow
Given this layout:
Midpoint is my reference point and in an array I have the vector points of all other points (P)
I can get to this state with code of having the light blue area by breaking it into four quadrants and doing a lame bubble sort to find largest(y) or lowest(x) value in each quadrant.
I need to find only the quadrants that outer border fully hits red no white space. For example the lower left and the up right dont have any white space hitting the light blue rectangle.
I am sure my terminology is all off here and im not looking for any specific code but if someone could point me to a more optimized solution for this problem or the next step in what I already have.
Thank you
I might do some BFI solution first, then perhaps look to generalize it or at least reduce it to a table-drive loop.
So, if it's exactly these shapes, and not a general solution, I think you should proceed sort of like this:
Derive the coordinates of the blue rectangle. I suspect one thing that's confusing you is that you have each individual x and y for the blue rect but you can't easily loop through them.
Derive the coordinates of the midpoint of each rectangle edge. You are going to need this because you care about quadrants. It will be trivial to do this once you have done 1.
Write different code for each 1/2 rectangle edge. There is no doubt a more clever way but this will get working code.
Make it more elegant now if you care. I betg you can reduce the rules to an 8-row
table full of things like 1, -1, or something like that.
First, you can't define red area by a single vector, since it's disjoint. You need the same number of vectors as the number of distant red regions.
Second, do we assume that different red figures neither intersect nor share a border? In the next clause I do.
Third, under assumption in point 2, the quadrant will have all red outer side iff there exists a contiguous red figure that intersects both its axes (i.e. rays). To determine this for all quadrants, you should only traverse all (P) points in the order they're given. This takes linear time and solves the problem.