Search code examples
winforms3dplotilnumerics

Beginner ILNumerics Plotting Sphere example


failing to follow a begiiner example: create a interactove sphere with ILNumerics. I added the nuget package as reference and draging a ILPanel from the toolbar to my form.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ILNumerics; 
using ILNumerics.Drawing; 
using ILNumerics.Drawing.Plotting; 

namespace WindowsFormsApplication1 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void ilPanel1_Load_1(object sender, EventArgs e) {
            var scene = new ILScene(); 
            scene.Add(new ILSphere()); 
            ilPanel1.Scene = scene; 

        }
    }
}

It shows a sphere. But the sphere always is the full size of the window. Mouse rotation does not work either. What am I missing?


Solution

  • Instead of

    scene.Add(new ILSphere()); 
    

    you can add the sphere below the standard Camera in the scene:

    scene.Camera.Add(new ILSphere()); 
    

    This will give you the desired result. The camera creates its own coordinate system, positions objects within its subtree and provides all interactive options for them (rotation, zoom, pan etc.)