Mirror Position problem

Hi All...i've got serious problem here.I try to create mirror data based on the vertex position. The problem is: why my script only works on simple geometry?when i run on the higher geometry (above 1000 vertex) it still running but the result is not like my expectation.Here is my script...its only work for mirror x in worldspace for now.there is 2 version,the one is working an another is not.yo can check manually that the position each vertex is exactly have a mirror.
thanks for all feedbacks...

---------working-------------
--Create box simple
mybox=box lengthsegs:1 widthsegs:1 heightsegs:1
convertto mybox editable_poly

select mybox
-- Collect position data
position=for i in $.Verts collect i.pos

-- Copy data for comparison
comparison= deepcopy position

-- Change each value of X in comparison
for i=1 to comparison.count do
(
comparison[i][1]=-comparison[i][1]
)

temp=#() --Create array to save mirror data

--compare
for i in position do
( c=finditem comparison i
append temp c
)
print Temp

---------working-------------

---------NOT working-------------
--"Notes:The difference is just the number of segments of the box"-------

--Create box simple
mybox=box lengthsegs:1 widthsegs:3 heightsegs:1
convertto mybox editable_poly

select mybox
-- Collect position data
position=for i in $.Verts collect i.pos

-- Copy data for comparison
comparison= deepcopy position

-- Change each value of X in comparison
for i=1 to comparison.count do
(
comparison[i][1]=-comparison[i][1]
)

temp=#() --Create array to save mirror data

--compare
for i in position do
( c=finditem comparison i
append temp c
)
print Temp

---------Not working-------------

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Marco Brunetta's picture

It's a rounding error, even

It's a rounding error, even if the point3 look the same in the listener they are actually different by really reaaaaaaally small margin. If you manually try subtracting the two "matches" that findItem reports as different, you'll see that the result is not [0,0,0] but something like [9.53674e-007,0,0]

Ishak Suryo Laksono's picture

Hi thanks for your feedback

Hi thanks for your feedback and sorry for to long to reply this.
i know the script is fine,but the problem is the "0" result when finding item inside the array.It should be found when we check on the print result...but why the result is always "0"

i adds a few line to show you the error...(it just the format thing) and i put image in the attachment to make it clearly.....I hope somebody can explain to solve my problem
...same as previous,the different is just the widthsegs of the box in both script:

-------------WORKING--------------
mybox=box lengthsegs:1 widthsegs:1 heightsegs:1
convertto mybox editable_poly

select mybox
-- Collect position data
position=for i in $.Verts collect i.pos

-- Copy data for comparison
comparison= deepcopy position

-- Change each value of X in comparison
for i=1 to comparison.count do
(
comparison[i][1]=-comparison[i][1]
)

temp=#() --Create array to save mirror data

--compare
for i in position do
( c=finditem comparison i
append temp c
format "finding % \n in: % \n result: % \n" i comparison c
)
print Temp
---------------------------------------

-------------NOT WORKING--------------
mybox=box lengthsegs:1 widthsegs:3 heightsegs:1
convertto mybox editable_poly

select mybox
-- Collect position data
position=for i in $.Verts collect i.pos

-- Copy data for comparison
comparison= deepcopy position

-- Change each value of X in comparison
for i=1 to comparison.count do
(
comparison[i][1]=-comparison[i][1]
)

temp=#() --Create array to save mirror data

--compare
for i in position do
( c=finditem comparison i
append temp c
format "finding % \n in: % \n result: % \n" i comparison c
)
print Temp
---------------------------------------

AttachmentSize
script_error.jpg 154.73 KB
Anubis's picture

What means not works?

What means not works? finditem() returns item index if found and 0 if not. In the 2nd example finditem() function returns 0 for all items. Simple test:

array1 = #([1,0,0],[0,1,0],[0,0,1],[0,0,0])
array2 = deepcopy array1
for i=1 to array2.count do (array2[i][1] *= -1)
array1; array2  -- test them
temp=#()
for i in array1 do (
	c = findItem array2 i ; append temp c)
print temp -- 0, 2, 3, 4 -- the result is fine

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.