Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:38 06 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : The Great Colour Maximite 2 Octahedron Prize Challenge

     Page 6 of 11    
Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1129
Posted: 08:11pm 11 Nov 2020
Copy link to clipboard 
Print this post

  PeteCotton said  I always rotate off my base object (i.e. I always start with -250,0,0 etc.)

That explains the difference!

The rules state:
  Quote  Each iteration should rotate the octahedron 2 degrees about the x axis (pitch), 1 degrees about the y axis (yaw) and 0.5 degrees about the z axis (roll) around the centre of the octahedron.

Thus, I would argue that only your first iteration is following the rule. All your other iterations are rotating by something different.  

The judge may have to wade in here.
Visit Vegipete's *Mite Library for cool programs.
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 543
Posted: 08:31pm 11 Nov 2020
Copy link to clipboard 
Print this post

  vegipete said  

The rules state:
  Quote  Each iteration should rotate the octahedron 2 degrees about the x axis (pitch), 1 degrees about the y axis (yaw) and 0.5 degrees about the z axis (roll) around the centre of the octahedron.

Thus, I would argue that only your first iteration is following the rule. All your other iterations are rotating by something different.  

The judge may have to wade in here.


Ha ha   I would argue that point strongly. Each iteration the object is rotated by the specified amount. In fact, to be pedantic, the fact that mines arrives back at the original start point would suggest that mine is the only one that is meeting the brief   If you haven't arrived back, then you must be rotating by a different number (rounding error).

But in all honesty, I do jest, as I am fascinated to see what all of our code ends up looking like. There will be lots to learn!
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 503
Posted: 08:31pm 11 Nov 2020
Copy link to clipboard 
Print this post

vegipete, this makes sense

For each interaction, I'm rotating over the previous rotated coordinates. I only have the initial coordinates before starting the rotation process. I guess you are doing the same in your code, this is why we are ending with the polygon in the same position

We need the matherp opinion, he is the judge  
Edited 2020-11-12 06:36 by LeoNicolas
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 543
Posted: 09:05pm 11 Nov 2020
Copy link to clipboard 
Print this post

Ha. I just realised we're all Canadians. Must be something to do with winter weather keeping us indoors
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1129
Posted: 09:11pm 11 Nov 2020
Copy link to clipboard 
Print this post

Do you guys want my latest number?

These last few comments gave me a new hint, which took off almost 300ms!

My latest time: 1271 ms.

Two notes:
400 MHz Waveshare,
Firmware RC14!

I see that printing the coordinates at iteration 650 adds about 9 ms.
Visit Vegipete's *Mite Library for cool programs.
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 543
Posted: 09:16pm 11 Nov 2020
Copy link to clipboard 
Print this post

  vegipete said  

My latest time: 1271 ms.

I see that printing the coordinates at iteration 650 adds about 9 ms.

Absolutely brilliant.

I store my 650 values in an array and don't print them until the end, if that helps?
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 503
Posted: 09:28pm 11 Nov 2020
Copy link to clipboard 
Print this post

  PeteCotton said  
  vegipete said  

My latest time: 1271 ms.

I see that printing the coordinates at iteration 650 adds about 9 ms.

Absolutely brilliant.

I store my 650 values in an array and don't print them until the end, if that helps?


Good idea Pete, let's do it.


Amazing vegipete and Pete . We are squeezing our CMM2 processor to get the maximum performance as possible.  

I'm enjoying a lot this challenge, it's being very fun.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1129
Posted: 09:30pm 11 Nov 2020
Copy link to clipboard 
Print this post

  PeteCotton said  I store my 650 values in an array and don't print them until the end, if that helps?

That would be slower. Printing time is the same. You've added the copying time. All of 0.nothing ms. :-)
Visit Vegipete's *Mite Library for cool programs.
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 543
Posted: 09:42pm 11 Nov 2020
Copy link to clipboard 
Print this post

  vegipete said  
  PeteCotton said  I store my 650 values in an array and don't print them until the end, if that helps?

That would be slower. Printing time is the same. You've added the copying time. All of 0.nothing ms. :-)


Aha. Now it's my turn to play with semantics. I stop the timer after the 720th iteration and then print the 650th numbers. This fulfills the requirements.

Print the values after the 650th iteration. Check.
Stop the timer after the 720th iteration. Check.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1129
Posted: 09:43pm 11 Nov 2020
Copy link to clipboard 
Print this post

  PeteCotton said  Ha ha   I would argue that point strongly. Each iteration the object is rotated by the specified amount. In fact, to be pedantic, the fact that mines arrives back at the original start point would suggest that mine is the only one that is meeting the brief   If you haven't arrived back, then you must be rotating by a different number (rounding error).

But in all honesty, I do jest, as I am fascinated to see what all of our code ends up looking like. There will be lots to learn!

As I see it, it is NOT an issue of rounding error. These are actually 2 different geometrical transformations. Repeatedly rotating (x,y,z) (x,y,z) ... n times is different than a single rotation of (nx,ny,nz).

I must say, I understand transformation matrices and projection much better now than I did few days ago. Thank you for the programming camaraderie!
Visit Vegipete's *Mite Library for cool programs.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1129
Posted: 09:50pm 11 Nov 2020
Copy link to clipboard 
Print this post

  PeteCotton said  Aha. Now it's my turn to play with semantics. I stop the timer after the 720th iteration and then print the 650th numbers. This fulfills the requirements.

Print the values after the 650th iteration. Check.
Stop the timer after the 720th iteration. Check.


Fair point. I agree with your reading. Now I know where to gain almost 9 seconds if I need it.  

My code:
mode 1,8
cls
timer = 0

do bunch of wild and crazy math, draw some triangles

print timer
end

Total, 149 lines, including comments.
Visit Vegipete's *Mite Library for cool programs.
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 503
Posted: 10:06pm 11 Nov 2020
Copy link to clipboard 
Print this post

I agree, I'm learning a lot with you guys and with this challenge, thank you.

I guess we need to start counting the time from the first line.
All my variables declaration, options and the CLS are included in my time.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3350
Posted: 12:30am 12 Nov 2020
Copy link to clipboard 
Print this post

  PeteCotton said  Ha. I just realised we're all Canadians. Must be something to do with winter weather keeping us indoors  

I've been enjoying this all-Canadian show for days now. Usually forum traffic is pretty light in the Canadian evening.

Lance (married to a Canadian, permanent resident in the Atlantic bubble--south shore Nova Scotia).

(Honoring Remembrance Day)
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 503
Posted: 02:56am 12 Nov 2020
Copy link to clipboard 
Print this post

Thank you lizby  

This is my best time until now: 1179.94 ms
Adjusted time (x 1.18): 1392.32 ms

Firmware RC17
480MHz CMM2

 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 503
Posted: 04:15am 12 Nov 2020
Copy link to clipboard 
Print this post

Ok, I believe this will be my final version, I cannot see any new optimization, the code is very small, 64 lines only.

Total time: 1086.82 ms
Adjusted time (x 1.18): 1282.44 ms

Firmware RC17
480MHz CMM2

 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 543
Posted: 05:04pm 12 Nov 2020
Copy link to clipboard 
Print this post

  vegipete said  
I must say, I understand transformation matrices and projection much better now than I did few days ago. Thank you for the programming camaraderie!


  LeoNicolas said  I agree, I'm learning a lot with you guys and with this challenge, thank you.


Yes. Thank you guys as well. This sort of thing really has me re-living the "fun" aspect of programming from my youth.

  lizby said  
I've been enjoying this all-Canadian show for days now. Usually forum traffic is pretty light in the Canadian evening.

We had our first big dump of snow last week (Calgary area). It certainly makes it conducive to staying indoors and playing with the CMM2.

  LeoNicolas said  Ok, I believe this will be my final version, I cannot see any new optimization, the code is very small, 64 lines only.

Total time: 1086.82 ms
Adjusted time (x 1.18): 1282.44 ms

Fantastic. I cannot get mine below 1287ms (1518ms adjusted). I can't see any further optimisation I can do. (480mhz). Mines is 147 lines of code, but I could probably get it down to 100 by removing comments and stacking lines. My actual loop only has 20 lines of code in it. That's 99% of my time, and I'm not sure what else I can do to refine it.
Edited 2020-11-13 03:05 by PeteCotton
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 543
Posted: 06:29pm 12 Nov 2020
Copy link to clipboard 
Print this post

What is interesting is that the latest update null-and-voided a huge performance boost I had made (which is a good thing - it's a testament as to how much of a speed boost we got from the last update).

I pre-calculate which sides are opposite each other. This is a generic pre-calculation which will work on any 3D primitive with 6 or more sides. It's pretty common technique in games for objects like walls and boxes. But doesn't increase or decrease the speed of more complex objects.

Anyway, on each run this would save me calculating the cross product for sides where I had already rendered the opposite side (as it is impossible for both sides to be visible at the same time). This check kicked in 1280 times each run (saving me a tonne of calculations). However, now the calcs are so fast, that it's hardly making any difference at all (it only helps with the surface removal calcs, not the rotation calcs).

I'm going to leave it in the code though as it may be of interest to others.
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 503
Posted: 07:34pm 12 Nov 2020
Copy link to clipboard 
Print this post

Pete

Probably you can improve your time using matrix math operations instead of using basic to perform calculations. With exception of the projection, I'm performing all operations using matrix math. For rotation, I changed the loop to rotate each vertice to pure matrix multiplication. I'm performing 3 multiplications, one per axis. I'll try to figure out a way to rotate the 3 axis with only one matrix multiplication. If I'm able to do it, I can reduce my time.
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 543
Posted: 07:48pm 12 Nov 2020
Copy link to clipboard 
Print this post

  LeoNicolas said  Pete

Probably you can improve your time using matrix math operations instead of using basic to perform calculations. With exception of the projection, I'm performing all operations using matrix math. For rotation, I changed the loop to rotate each vertice to pure matrix multiplication. I'm performing 3 multiplications, one per axis. I'll try to figure out a way to rotate the 3 axis with only one matrix multiplication. If I'm able to do it, I can reduce my time.


Thanks. I have been calculating the matrix long hand. I didn't realise there was a built in matrix operation until you just mentioned it. Well, that's not 100% true. I read through the manual before and saw it, but in my old age I'm forgetting lots of things!

I'll try it out this evening when I finish work.
Edited 2020-11-13 05:48 by PeteCotton
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 09:53pm 12 Nov 2020
Copy link to clipboard 
Print this post

Obviously I'm not the judge, but if you consider the rationale behind this challenge, the desire to provide an API for doing generic 3D graphics, then it really should be doing the rotation based on the initial state, not off the previous iteration. That's how 3D systems typically work.
 
     Page 6 of 11    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025