PDA

View Full Version : Polygon from 3 existing points


MrBraun
06-27-2007, 07:50 AM
Hello to all, again with a little request: i would realise one small script that permits to create a polygon fom 3 point.

I select 3 point and the 4^ point are determined from the coordinate of the other points.

For example, if i have a A(X,Y), B(x1,y1), C(x2,y2) (clockwise selection), the 4^ point that close a polygon are: D(x2,y).

I hope that is clear! ;)

Tnx in advance

MrB

Per-Anders
06-27-2007, 08:02 AM
Is there any reason why you wouldn't want to just use the Create Polygon tool or the Bridge tool? (or the close polygon hole tool if the points are around an existing hole in the mesh)?

In scripting or coding you do it by resizing the polygon array of your object and then simply setting the indeces of the new polygon to your existing points. COFFEE only handles quads and tri's which is fine for what you want here (but if you wanted to build bigger ngon polygons you'd need to use C++), check out the VariableChanged object and examples in the COFFEE SDK docs to see how it works. There is no selection order in C4D, all it will see is the selected points, not which order they were selected in, you will have to work out your own winding order.

MrBraun
06-27-2007, 08:20 AM
Tnx for the answer Per-Anders! I have realised a couple of image to best explain what i want to make! (sorry for my poor english!)

MrB

Per-Anders
06-27-2007, 08:29 AM
You could just extrude down the top edge then melt the additional corner point for that example, or you could just use the make polygon tool and simply draw the extra point after first clicking the other three.

However to do what you're explaining there in scripting or coding it's just a simple matter of taking the midpoint along the hypotenuse m = (a + c) / 2, the vector of that to the opposite corner v = m - b adding that on again d = m + v and then you have your new parallelogram point, resize the points array, add it in, resize your polygons array and set the new polygons points to a b c d.

MrBraun
06-27-2007, 10:39 AM
Tnx again Per-Anders for the answer! ;)

3DBond
06-28-2007, 01:29 PM
Hey Per, if you do it using the Create Poly tool, how can you ensure that the last point is on the correct plane given the object is round?

Would one need to explore the Coordinates manager or is there is 'simpler' way?

Per-Anders
06-28-2007, 06:28 PM
By default in the make polygon tool the next point is on the same plane (relative to the camera) as the last point. So, for example one way would be to use an orthographic view and do the elft two points first then the top point to the right and finally the missing point. Otherwise it's down to how you've oriented your camera.

CGTalk Moderation
06-28-2007, 06:28 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.