Esempio n. 1
0
        public void Update(ILPoint3Df center, float zoomFactor)
        {
            if (zoomFactor == 1.0f && center == CenterF)
            {
                return;
            }
            m_isDirty = true;
            float s = WidthF * zoomFactor / 2;

            m_xMin = center.X - s;
            m_xMax = center.X + s;
            s      = HeightF * zoomFactor / 2;
            m_yMin = center.Y - s;
            m_yMax = center.Y + s;
            s      = DepthF * zoomFactor / 2;
            m_zMin = center.Z - s;
            m_zMax = center.Z + s;
            if (!m_allowZeroVolume)
            {
                ensureVolumeNotZero();
            }
            m_sphereRadius = getSphereRadius();
            if (m_eventingActive && Changed != null)
            {
                OnChange();
            }
        }
Esempio n. 2
0
        private void createBoxes() {

            ILNumerics.Drawing.Misc.ILColormap cm = new ILNumerics.Drawing.Misc.ILColormap(Colormaps.Hsv); 
            m_boxes = new List<ILLitBox3D>(); 
            float [] xPos = new float[] {12,12,12,13,13,13,14,14,14,15,15,15,16,16,16,17,17,17,17,18,18,18,18,19,19,19,20,20,20}; 
            float [] yPos = new float[] {28,29,30,28,29,30,28,29,30,28,29,30,28,29,30,28,29,30,31,28,29,30,31,29,30,31,29,30,31}; 
            float [] zVal = new float[] {0.02f,0.316f,0.523f,0.0223f,0.283f,0.471f,0.0074f,0.17f,0.409f,0.021f,0.3f,0.5f,0.0191f,0.187f,0.337f,0.02f,0.07f,0.52f,0.64f,0.06f,0.22f,0.3f,0.48f,0.17f,0.21f,0.63f,0.1f,0.17f,0.3f};
            byte [] tran = new byte[] {30,30,30,70,70,70,190,190,190};  
            for (int i = 0; i < xPos.Length; i++) {
                ILLitBox3D box; 
                ILPoint3Df min = new ILPoint3Df(
                        -m_max + xPos[i]+0.05 + 4 + m_linesPositionOffset, 
                        -m_max + yPos[i]+0.05 - 2 + m_linesPositionOffset, 
                        -zVal[i]); 
                ILPoint3Df max = new ILPoint3Df(
                        -m_max + xPos[i]+0.9 + 4 + m_linesPositionOffset, 
                        -m_max + yPos[i]+0.9 - 2 + m_linesPositionOffset, 
                        zVal[i]); 
                box = new ILLitBox3D(m_panel, min, max, cm.Map((double)zVal[i]*cm.Length), cm.Map((double)zVal[i]*cm.Length));
                box.TopLabel.Text = ""; 
                box.GradientColor = box.TopColor; 
                box.Edges.Color = Color.DarkGray;
                if (tran.Length > i) {
                    //box.Opacity = tran[i]; 
                }
                box.Quads[ILLitBox3D.QuadIndices.bottom].CustomCenter = new ILPoint3Df(0,0,3000);  
                box.Quads[ILLitBox3D.QuadIndices.top].CustomCenter = new ILPoint3Df(0,0,3000);  
                m_boxes.Add(box); 
                Add(box); 
            }
        }
Esempio n. 3
0
 /// <summary>
 /// cross product
 /// </summary>
 /// <param name="a">vector 1</param>
 /// <param name="b">vector 2</param>
 /// <returns>normalized cross product between a x b</returns>
 public static ILPoint3Df cross(ILPoint3Df a, ILPoint3Df b)
 {
     return(new ILPoint3Df(
                a.Y * b.Z - a.Z * b.Y,
                a.Z * b.X - a.X * b.Z,
                a.X * b.Y - a.Y * b.X));
 }
Esempio n. 4
0
        /// <summary>
        /// stretch clipping region to unit cube [0 1][0 1][0 1]
        /// </summary>
        /// <returns></returns>
        public ILPoint3Df ScaleToUnitCube()
        {
            ILPoint3Df ret = new ILPoint3Df();
            float      a   = WidthF;

            if (a != 0.0f)
            {
                ret.X = 1 / a;
            }
            else
            {
                ret.X = 0.0f;
            }

            a = HeightF;
            if (a != 0.0f)
            {
                ret.Y = 1 / a;
            }
            else
            {
                ret.Y = 0.0f;
            }

            a = DepthF;
            if (a != 0.0f)
            {
                ret.Z = 1 / a;
            }
            else
            {
                ret.Z = 0.0f;
            }
            return(ret);
        }
Esempio n. 5
0
        public static ILPoint3Df operator -(ILPoint3Df p1, ILPoint3Df p2)
        {
            ILPoint3Df ret = new ILPoint3Df();

            ret.X = p1.X - p2.X;
            ret.Y = p1.Y - p2.Y;
            ret.Z = p1.Z - p2.Z;
            return(ret);
        }
Esempio n. 6
0
        /// <summary>
        /// update clipping data for this object with union of this and rectangle specified
        /// </summary>
        /// <param name="luCorner">left upper corner</param>
        /// <param name="rbCorner">right lower corner</param>
        public void Update(ILPoint3Df luCorner, ILPoint3Df rbCorner)
        {
            bool oldeventState = m_eventingActive;

            m_eventingActive = false;
            Update(luCorner, 7);
            m_eventingActive = oldeventState;
            Update(rbCorner, 7);
        }
Esempio n. 7
0
        public static ILPoint3Df operator /(ILPoint3Df p1, float factor)
        {
            ILPoint3Df ret = new ILPoint3Df();

            ret.X = p1.X / factor;
            ret.Y = p1.Y / factor;
            ret.Z = p1.Z / factor;
            return(ret);
        }
Esempio n. 8
0
        /// <summary>
        /// normalized cross product
        /// </summary>
        /// <param name="a">vector 1</param>
        /// <param name="b">vector 2</param>
        /// <returns>normalized cross product: a x b</returns>
        public static ILPoint3Df crossN(ILPoint3Df a, ILPoint3Df b)
        {
            ILPoint3Df ret = new ILPoint3Df(
                a.Y * b.Z - a.Z * b.Y,
                a.Z * b.X - a.X * b.Z,
                a.X * b.Y - a.Y * b.X);
            float len = (float)Math.Sqrt(ret.X * ret.X + ret.Z * ret.Z + ret.Y * ret.Y);

            if (len != 0)
            {
                return(ret / len);
            }
            return(ret);
        }
Esempio n. 9
0
        /// <summary>
        /// offset centering scaled unit cube to zero: [-0.5 0.5][-0.5 0.5][-0.5 0.5]
        /// </summary>
        /// <returns></returns>
        public ILPoint3Df CenterToUnitCube()
        {
            ILPoint3Df a = ScaleToUnitCube();
            ILPoint3Df b = new ILPoint3Df();

            b.X = -0.5f - a.X * XMin;
            b.Y = -0.5f - a.Y * YMin;
            if (ZMin < ZMax)
            {
                b.Z = (-0.5f - a.Z * ZMin);
            }
            else
            {
                b.Z = 0.0f;
            }
            return(b);
        }
Esempio n. 10
0
        private void updateCachedVars()
        {
            CosPhi      = (float)Math.Cos(m_phi);
            SinPhi      = (float)Math.Sin(m_phi);
            SinPhiShift = (float)Math.Sin(m_phi + Offset);
            CosPhiShift = (float)Math.Cos(m_phi + Offset);
            CosRho      = (float)Math.Cos(m_rho);
            SinRho      = (float)Math.Sin(m_rho);
            // update top
            ILPoint3Df top = ILPoint3Df.normalize(-SinPhi * CosRho, CosPhi * CosRho, SinRho);

            m_topX = top.X;
            m_topY = top.Y;
            m_topZ = top.Z;

            computeQuadrant();
        }
Esempio n. 11
0
 /// <summary>
 /// update ranges for this object with point coords for specific axes
 /// </summary>
 /// <param name="point">point with coords to update ranges with</param>
 /// <param name="updateBitFlags">bitflag combination to specify axis to be recognized: 1,2,4 -> x,y,z</param>
 public void Update(ILPoint3Df point, int updateBitFlags)
 {
     if ((updateBitFlags & 1) != 0)
     {
         if (point.X < XMin)
         {
             m_isDirty = true; m_xMin = point.X;
         }
         if (point.X > XMax)
         {
             m_isDirty = true; m_xMax = point.X;
         }
     }
     if ((updateBitFlags & 2) != 0)
     {
         if (point.Y < YMin)
         {
             m_isDirty = true; m_yMin = point.Y;
         }
         if (point.Y > YMax)
         {
             m_isDirty = true; m_yMax = point.Y;
         }
     }
     if ((updateBitFlags & 4) != 0)
     {
         if (point.Z < ZMin)
         {
             m_isDirty = true; m_zMin = point.Z;
         }
         if (point.Z > ZMax)
         {
             m_isDirty = true; m_zMax = point.Z;
         }
     }
     if (!m_allowZeroVolume)
     {
         ensureVolumeNotZero();
     }
     m_sphereRadius = getSphereRadius();
     if (m_isDirty && m_eventingActive && Changed != null)
     {
         OnChange();
     }
 }
Esempio n. 12
0
        public static ILPoint3Df Max(ILPoint3Df val1, ILPoint3Df val2)
        {
            ILPoint3Df ret = val1;

            if (val2.X > val1.X)
            {
                ret.X = val2.X;
            }
            if (val2.Y > val1.Y)
            {
                ret.Y = val2.Y;
            }
            if (val2.Z > val1.Z)
            {
                ret.Z = val2.Z;
            }
            return(ret);
        }
Esempio n. 13
0
 /// <summary>
 /// Set clipping limits to volume inside the box specified
 /// </summary>
 /// <param name="lunCorner">left-upper-near corner of the volume box</param>
 /// <param name="rbfCorner">right-bottom-far corner of the volume box</param>
 public void Set(ILPoint3Df lunCorner, ILPoint3Df rbfCorner)
 {
     m_isDirty = true;
     m_xMin    = Math.Min(lunCorner.X, rbfCorner.X);
     m_xMax    = Math.Max(lunCorner.X, rbfCorner.X);
     m_yMin    = Math.Min(lunCorner.Y, rbfCorner.Y);
     m_yMax    = Math.Max(lunCorner.Y, rbfCorner.Y);
     m_zMin    = Math.Min(lunCorner.Z, rbfCorner.Z);
     m_zMax    = Math.Max(lunCorner.Z, rbfCorner.Z);
     if (!m_allowZeroVolume)
     {
         ensureVolumeNotZero();
     }
     m_sphereRadius = getSphereRadius();
     if (m_eventingActive && Changed != null)
     {
         OnChange();
     }
 }
Esempio n. 14
0
        public static ILPoint3Df Max(ILPoint3Df val1, ILPoint3Df val2, ref bool changed)
        {
            ILPoint3Df ret = val1;

            if (val2.X > val1.X)
            {
                ret.X   = val2.X;
                changed = true;
            }
            if (val2.Y > val1.Y)
            {
                ret.Y   = val2.Y;
                changed = true;
            }
            if (val2.Z > val1.Z)
            {
                ret.Z   = val2.Z;
                changed = true;
            }
            return(ret);
        }
Esempio n. 15
0
        /// <summary>
        /// rotate the vector, keep length
        /// </summary>
        /// <param name="normal">axis as rotation normal</param>
        /// <param name="angleDeg">angle to move (radian)</param>
        /// <returns>rotated version of this vector, does not change original vector</returns>
        public ILPoint3Df Spin(ILPoint3Df normal, float angleDeg)
        {
            float a    = angleDeg * (float)Math.PI / 180f;
            float cosa = (float)Math.Cos(a);
            float sina = (float)Math.Sin(a);

            normal = ILPoint3Df.normalize(normal);
            float      omincosa = 1 - cosa;
            ILPoint3Df ret      = new ILPoint3Df(
                (cosa + X * X * omincosa) * normal.X
                + (X * Y * omincosa - Z * sina) * normal.Y
                + (X * Z * omincosa + Y * sina) * normal.Z,

                (Y * X * omincosa + Z * sina) * normal.X
                + (cosa + Y * Y * omincosa) * normal.Y
                + (Y * Z * omincosa - X * sina) * normal.Z,

                (Z * X * omincosa - Y * sina) * normal.X
                + (Z * Y * omincosa + X * sina) * normal.Y
                + (cosa + Z * Z * omincosa) * normal.Z);

            return(ret);
        }
Esempio n. 16
0
 /// <summary>
 /// Expand/shrink all those edges, not touched by the given line
 /// </summary>
 /// <param name="nearLineEnd">near line point</param>
 /// <param name="farLineEnd">far line point</param>
 /// <param name="offset">multiplicator, shrink-/expand value</param>
 public void GetZoomParameter(ILPoint3Df nearLineEnd, ILPoint3Df farLineEnd, float offset, 
                 out ILPoint3Df minCorner, out ILPoint3Df maxCorner) {
     // we determine, if the side is touched by the line. 
     // if 'yes': the side is skipped (its limit/position are kept)
     // if 'no': the side is moved towards/away from center
     minCorner = this.Min;
     maxCorner = this.Max; 
     float sX, sY, sZ; 
     float lamb; 
     float aX = nearLineEnd.X - farLineEnd.X;
     float aY = nearLineEnd.Y - farLineEnd.Y;
     float aZ = nearLineEnd.Z - farLineEnd.Z;
     float offX = WidthF * (offset/2.0f);
     float offY = HeightF * (offset/2.0f);
     float offZ = DepthF * (offset/2.0f); 
     #region front side
     lamb = (m_yMin - nearLineEnd.Y) / aY; 
     sX = nearLineEnd.X + lamb * aX;
     sZ = nearLineEnd.Z + lamb * aZ;
     if (sX > m_xMax || sX < m_xMin || sZ > m_zMax || sZ < m_zMin) {
         minCorner.Y += offY; 
     }
     #endregion
     #region right side
     lamb = (m_xMax - nearLineEnd.X) / aX;
     sY = nearLineEnd.Y + lamb * aY;
     sZ = nearLineEnd.Z + lamb * aZ;
     if (sY > m_yMax || sY < m_yMin || sZ > m_zMax || sZ < m_zMin) {
         maxCorner.X -= offX;
     }
     #endregion
     #region back side
     lamb = (m_yMax - nearLineEnd.Y) / aY;
     sX = nearLineEnd.X + lamb * aX;
     sZ = nearLineEnd.Z + lamb * aZ;
     if (sX > m_xMax || sX < m_xMin || sZ > m_zMax || sZ < m_zMin) {
         maxCorner.Y -= offY;
     }
     #endregion
     #region left side
     lamb = (m_xMin - nearLineEnd.X) / aX;
     sY = nearLineEnd.Y + lamb * aY;
     sZ = nearLineEnd.Z + lamb * aZ;
     if (sY > m_yMax || sY < m_yMin || sZ > m_zMax || sZ < m_zMin) {
         minCorner.X += offX;
     }
     #endregion
     #region top side
     lamb = (m_zMax - nearLineEnd.Z) / aZ;
     sX = nearLineEnd.X + lamb * aX;
     sY = nearLineEnd.Y + lamb * aY;
     if (sY > m_yMax || sY < m_yMin || sX > m_xMax || sX < m_xMin) {
         maxCorner.Z -= offZ;
     }
     #endregion
     #region bottom side
     lamb = (m_zMin - nearLineEnd.Z) / aZ;
     sX = nearLineEnd.X + lamb * aX;
     sY = nearLineEnd.Y + lamb * aY;
     if (sY > m_yMax || sY < m_yMin || sX > m_xMax || sX < m_xMin) {
         minCorner.Z += offZ;
     }
     #endregion
     #region translate: move line to cross middle of view cube
     ILPoint3Df rQ =  CenterF; 
     sX = rQ.X - nearLineEnd.X; 
     sY = rQ.Y - nearLineEnd.Y; 
     sZ = rQ.Z - nearLineEnd.Z; 
     lamb = (aX * sX + aY * sY + aZ * sZ) / (aX * aX + aY * aY + aZ * aZ);
     offX = rQ.X - (nearLineEnd.X + lamb * aX);
     offY = rQ.Y - (nearLineEnd.Y + lamb * aY);
     offZ = rQ.Z - (nearLineEnd.Z + lamb * aZ);
     minCorner.X -= offX;
     minCorner.Y -= offY;
     minCorner.Z -= offZ;
     maxCorner.X -= offX;
     maxCorner.Y -= offY;
     maxCorner.Z -= offZ;
     #endregion
 }
Esempio n. 17
0
 /// <summary>
 /// offset centering scaled unit cube to zero: [-0.5 0.5][-0.5 0.5][-0.5 0.5]
 /// </summary>
 /// <returns></returns>
 public ILPoint3Df CenterToUnitCube() {
     ILPoint3Df a = ScaleToUnitCube(); 
     ILPoint3Df b = new ILPoint3Df(); 
     b.X = -0.5f - a.X * XMin; 
     b.Y = -0.5f - a.Y * YMin; 
     if (ZMin < ZMax)
         b.Z = (-0.5f - a.Z * ZMin); 
     else b.Z = 0.0f; 
     return b; 
 }
Esempio n. 18
0
        /// <summary>
        /// stretch clipping region to unit cube [0 1][0 1][0 1] 
        /// </summary>
        /// <returns></returns>
        public ILPoint3Df ScaleToUnitCube () {
            ILPoint3Df ret = new ILPoint3Df(); 
            float a = WidthF; 
            if (a != 0.0f)  ret.X = 1 / a;
            else            ret.X = 0.0f; 

            a = HeightF; 
            if (a != 0.0f)  ret.Y = 1 / a;
            else            ret.Y = 0.0f; 

            a = DepthF; 
            if (a != 0.0f)  ret.Z = 1 / a;
            else            ret.Z = 0.0f; 
            return ret; 
        }
Esempio n. 19
0
 /// <summary>
 /// Set clipping limits to volume inside the box specified 
 /// </summary>
 /// <param name="lunCorner">left-upper-near corner of the volume box</param>
 /// <param name="rbfCorner">right-bottom-far corner of the volume box</param>
 public void Set(ILPoint3Df lunCorner, ILPoint3Df rbfCorner) {
     m_isDirty = true; 
     m_xMin = Math.Min(lunCorner.X,rbfCorner.X); 
     m_xMax = Math.Max(lunCorner.X,rbfCorner.X); 
     m_yMin = Math.Min(lunCorner.Y,rbfCorner.Y); 
     m_yMax = Math.Max(lunCorner.Y,rbfCorner.Y); 
     m_zMin = Math.Min(lunCorner.Z,rbfCorner.Z); 
     m_zMax = Math.Max(lunCorner.Z,rbfCorner.Z);
     if (!m_allowZeroVolume) ensureVolumeNotZero();
     m_sphereRadius = getSphereRadius();
     if (m_eventingActive && Changed != null) 
         OnChange(); 
 }
Esempio n. 20
0
 public void Update (ILPoint3Df center, float zoomFactor) {
     if (zoomFactor == 1.0f && center == CenterF) return; 
     m_isDirty = true; 
     float s = WidthF * zoomFactor / 2; 
     m_xMin = center.X - s; 
     m_xMax = center.X + s; 
     s = HeightF * zoomFactor / 2; 
     m_yMin = center.Y - s; 
     m_yMax = center.Y + s; 
     s = DepthF * zoomFactor / 2; 
     m_zMin = center.Z - s; 
     m_zMax = center.Z + s;
     if (!m_allowZeroVolume) ensureVolumeNotZero();
     m_sphereRadius = getSphereRadius();
     if (m_eventingActive && Changed != null) 
         OnChange();  
 }
Esempio n. 21
0
 /// <summary>
 /// update clipping data for this object with union of this and rectangle specified
 /// </summary>
 /// <param name="luCorner">left upper corner</param>
 /// <param name="rbCorner">right lower corner</param>
 public void Update (ILPoint3Df luCorner, ILPoint3Df rbCorner) {
     bool oldeventState = m_eventingActive; 
     m_eventingActive = false; 
     Update(luCorner,7);
     m_eventingActive = oldeventState; 
     Update(rbCorner,7);
 }
Esempio n. 22
0
 /// <summary>
 /// update ranges for this object with point coords for specific axes
 /// </summary>
 /// <param name="point">point with coords to update ranges with</param>
 /// <param name="updateBitFlags">bitflag combination to specify axis to be recognized: 1,2,4 -> x,y,z</param>
 public void Update (ILPoint3Df point, int updateBitFlags) {
     if ((updateBitFlags & 1) != 0) {
         if (point.X < XMin) { m_isDirty = true; m_xMin = point.X; }
         if (point.X > XMax) { m_isDirty = true; m_xMax = point.X; }
     }
     if ((updateBitFlags & 2) != 0) {
         if (point.Y < YMin) { m_isDirty = true; m_yMin = point.Y; }
         if (point.Y > YMax) { m_isDirty = true; m_yMax = point.Y; }
     }
     if ((updateBitFlags & 4) != 0) {
         if (point.Z < ZMin) { m_isDirty = true; m_zMin = point.Z; }
         if (point.Z > ZMax) { m_isDirty = true; m_zMax = point.Z; }
     }
     if (!m_allowZeroVolume) ensureVolumeNotZero();
     m_sphereRadius = getSphereRadius();
     if (m_isDirty && m_eventingActive && Changed != null) 
         OnChange(); 
 }
Esempio n. 23
0
        /// <summary>
        /// rotate the vector, keep length
        /// </summary>
        /// <param name="normal">axis as rotation normal</param>
        /// <param name="angleDeg">angle to move (radian)</param>
        /// <returns>rotated version of this vector, does not change original vector</returns>
        public ILPoint3Df Spin(ILPoint3Df normal, float angleDeg) {
            float a = angleDeg * (float)Math.PI / 180f;
            float cosa = (float)Math.Cos(a);
            float sina = (float)Math.Sin(a);
            normal = ILPoint3Df.normalize(normal);
            float omincosa = 1 - cosa;
            ILPoint3Df ret = new ILPoint3Df(
                (cosa + X * X * omincosa) * normal.X
                + (X * Y * omincosa - Z * sina) * normal.Y
                + (X * Z * omincosa + Y * sina) * normal.Z,

                (Y * X * omincosa + Z * sina) * normal.X
                + (cosa + Y * Y * omincosa) * normal.Y
                + (Y * Z * omincosa - X * sina) * normal.Z,

                (Z * X * omincosa - Y * sina) * normal.X
                + (Z * Y * omincosa + X * sina) * normal.Y
                + (cosa + Z * Z * omincosa) * normal.Z);
            return ret; 
        }
Esempio n. 24
0
 private void cart2Pol(ILPoint3Df cartVec)
 {
     cartVec.ToPolar(out m_distance, out m_phi, out m_rho);
 }
Esempio n. 25
0
 private void create(ILBaseArray data, Colormaps colormap) {
     ILArray<float> dataF = ILNumerics.BuiltInFunctions.ILMath.tosingle(data); 
     m_boxes = new ILLitBox3D[data.Dimensions[0],data.Dimensions[1]];
     float maxY = data.Dimensions[0] * (m_barLengthY + m_paddingY);
     // prepare coloring for top quads 
     ILColormap cmap = new ILColormap(colormap); 
     float minV,maxV,mult;
     dataF.GetLimits(out minV, out maxV);
     if (maxV > minV) {
         mult = (cmap.Length - 1) / (maxV - minV);
     } else {
         minV = 0; 
         mult = 0;
     }
     for (int r = 0; r < data.Dimensions[0]; r++) {
         for (int c = 0; c < data.Dimensions[1]; c++) {
             float val = dataF.GetValue(r, c);  
             ILPoint3Df max = new ILPoint3Df(
                 (float)(c * (m_paddingX + m_barLengthX) + m_barLengthX)
                 , (float)(maxY - r * (m_paddingY + m_barLengthY))
                 , val);
             ILPoint3Df min = new ILPoint3Df(
                 max.X - m_barLengthX
                 , max.Y - m_barLengthY
                 , 0);
             Color topColor = cmap.Map((double)(val - minV) * mult); 
             ILLitBox3D box = new ILLitBox3D(m_panel,min,max,m_barColor,topColor);
             box.GradientColor = m_barColorGradient;
             box.TopLabel.Color = topColor;
             box.TopLabel.Text = ""; 
             m_boxes[r, c] = box; 
             Add(box); 
         }
     }
 }
Esempio n. 26
0
 public static ILPoint3Df operator - (ILPoint3Df p1, ILPoint3Df p2) {
     ILPoint3Df ret = new ILPoint3Df(); 
     ret.X = p1.X - p2.X; 
     ret.Y = p1.Y - p2.Y; 
     ret.Z = p1.Z - p2.Z; 
     return ret; 
 }
Esempio n. 27
0
 /// <summary>
 /// normalized cross product
 /// </summary>
 /// <param name="a">vector 1</param>
 /// <param name="b">vector 2</param>
 /// <returns>normalized cross product: a x b</returns>
 public static ILPoint3Df crossN(ILPoint3Df a, ILPoint3Df b) {
     ILPoint3Df ret = new ILPoint3Df(
         a.Y * b.Z - a.Z * b.Y,
         a.Z * b.X - a.X * b.Z,
         a.X * b.Y - a.Y * b.X); 
     float len = (float)Math.Sqrt(ret.X * ret.X + ret.Z * ret.Z + ret.Y * ret.Y); 
     if (len != 0)
         return (ret / len); 
     return ret; 
 }
Esempio n. 28
0
 /// <summary>
 /// cross product
 /// </summary>
 /// <param name="a">vector 1</param>
 /// <param name="b">vector 2</param>
 /// <returns>normalized cross product between a x b</returns>
 public static ILPoint3Df cross(ILPoint3Df a, ILPoint3Df b) {
     return new ILPoint3Df(
         a.Y * b.Z - a.Z * b.Y,
         a.Z * b.X - a.X * b.Z,
         a.X * b.Y - a.Y * b.X);     
 }
Esempio n. 29
0
 public static ILPoint3Df operator / (ILPoint3Df p1, float factor) {
     ILPoint3Df ret = new ILPoint3Df(); 
     ret.X = p1.X / factor; 
     ret.Y = p1.Y / factor; 
     ret.Z = p1.Z / factor; 
     return ret; 
 }
Esempio n. 30
0
        public static ILPoint3Df normalize(ILPoint3Df p)
        {
            float length = (float)Math.Sqrt(p.X * p.X + p.Y * p.Y + p.Z * p.Z);

            return(p / length);
        }
Esempio n. 31
0
 private void cart2Pol(ILPoint3Df cartVec) {
     cartVec.ToPolar(out m_distance, out m_phi, out m_rho);
 }
Esempio n. 32
0
 public static ILPoint3Df Min(ILPoint3Df val1, ILPoint3Df val2) {
     ILPoint3Df ret = val1; 
     if (val2.X < val1.X) ret.X = val2.X; 
     if (val2.Y < val1.Y) ret.Y = val2.Y; 
     if (val2.Z < val1.Z) ret.Z = val2.Z; 
     return ret; 
 }
Esempio n. 33
0
 public static ILPoint3Df normalize(ILPoint3Df p) {
     float length = (float)Math.Sqrt(p.X * p.X + p.Y * p.Y + p.Z * p.Z);
     return p / length;                 
 }
Esempio n. 34
0
        /// <summary>
        /// Expand/shrink all those edges, not touched by the given line
        /// </summary>
        /// <param name="nearLineEnd">near line point</param>
        /// <param name="farLineEnd">far line point</param>
        /// <param name="offset">multiplicator, shrink-/expand value</param>
        public void GetZoomParameter(ILPoint3Df nearLineEnd, ILPoint3Df farLineEnd, float offset,
                                     out ILPoint3Df minCorner, out ILPoint3Df maxCorner)
        {
            // we determine, if the side is touched by the line.
            // if 'yes': the side is skipped (its limit/position are kept)
            // if 'no': the side is moved towards/away from center
            minCorner = this.Min;
            maxCorner = this.Max;
            float sX, sY, sZ;
            float lamb;
            float aX   = nearLineEnd.X - farLineEnd.X;
            float aY   = nearLineEnd.Y - farLineEnd.Y;
            float aZ   = nearLineEnd.Z - farLineEnd.Z;
            float offX = WidthF * (offset / 2.0f);
            float offY = HeightF * (offset / 2.0f);
            float offZ = DepthF * (offset / 2.0f);

            #region front side
            lamb = (m_yMin - nearLineEnd.Y) / aY;
            sX   = nearLineEnd.X + lamb * aX;
            sZ   = nearLineEnd.Z + lamb * aZ;
            if (sX > m_xMax || sX < m_xMin || sZ > m_zMax || sZ < m_zMin)
            {
                minCorner.Y += offY;
            }
            #endregion
            #region right side
            lamb = (m_xMax - nearLineEnd.X) / aX;
            sY   = nearLineEnd.Y + lamb * aY;
            sZ   = nearLineEnd.Z + lamb * aZ;
            if (sY > m_yMax || sY < m_yMin || sZ > m_zMax || sZ < m_zMin)
            {
                maxCorner.X -= offX;
            }
            #endregion
            #region back side
            lamb = (m_yMax - nearLineEnd.Y) / aY;
            sX   = nearLineEnd.X + lamb * aX;
            sZ   = nearLineEnd.Z + lamb * aZ;
            if (sX > m_xMax || sX < m_xMin || sZ > m_zMax || sZ < m_zMin)
            {
                maxCorner.Y -= offY;
            }
            #endregion
            #region left side
            lamb = (m_xMin - nearLineEnd.X) / aX;
            sY   = nearLineEnd.Y + lamb * aY;
            sZ   = nearLineEnd.Z + lamb * aZ;
            if (sY > m_yMax || sY < m_yMin || sZ > m_zMax || sZ < m_zMin)
            {
                minCorner.X += offX;
            }
            #endregion
            #region top side
            lamb = (m_zMax - nearLineEnd.Z) / aZ;
            sX   = nearLineEnd.X + lamb * aX;
            sY   = nearLineEnd.Y + lamb * aY;
            if (sY > m_yMax || sY < m_yMin || sX > m_xMax || sX < m_xMin)
            {
                maxCorner.Z -= offZ;
            }
            #endregion
            #region bottom side
            lamb = (m_zMin - nearLineEnd.Z) / aZ;
            sX   = nearLineEnd.X + lamb * aX;
            sY   = nearLineEnd.Y + lamb * aY;
            if (sY > m_yMax || sY < m_yMin || sX > m_xMax || sX < m_xMin)
            {
                minCorner.Z += offZ;
            }
            #endregion
            #region translate: move line to cross middle of view cube
            ILPoint3Df rQ = CenterF;
            sX           = rQ.X - nearLineEnd.X;
            sY           = rQ.Y - nearLineEnd.Y;
            sZ           = rQ.Z - nearLineEnd.Z;
            lamb         = (aX * sX + aY * sY + aZ * sZ) / (aX * aX + aY * aY + aZ * aZ);
            offX         = rQ.X - (nearLineEnd.X + lamb * aX);
            offY         = rQ.Y - (nearLineEnd.Y + lamb * aY);
            offZ         = rQ.Z - (nearLineEnd.Z + lamb * aZ);
            minCorner.X -= offX;
            minCorner.Y -= offY;
            minCorner.Z -= offZ;
            maxCorner.X -= offX;
            maxCorner.Y -= offY;
            maxCorner.Z -= offZ;
            #endregion
        }
Esempio n. 35
0
 public static ILPoint3Df Max(ILPoint3Df val1, ILPoint3Df val2) {
     ILPoint3Df ret = val1; 
     if (val2.X > val1.X) ret.X = val2.X; 
     if (val2.Y > val1.Y) ret.Y = val2.Y; 
     if (val2.Z > val1.Z) ret.Z = val2.Z; 
     return ret; 
 }
Esempio n. 36
0
         /// <summary>
         /// create new lit 3D box
         /// </summary>
         /// <param name="panel">panel hosting the scene</param>
         /// <param name="min">minimum coordinates defining the box' dimensions (x,y,z)</param>
         /// <param name="max">minimum coordinates defining the box' dimensions (x,y,z)</param>
         /// <param name="fillColor">overall color for the box</param>
         /// <param name="topColor">color used to color the top edges of the box</param>
         public ILLitBox3D(ILPanel panel, ILPoint3Df min, ILPoint3Df max, Color fillColor, Color topColor)
             : base(panel) {
             m_lineProperties = new ILLineProperties();
             m_lineProperties.Changed += new EventHandler(m_lineProperties_Changed);
             m_valLabel = new ILWorldLabel(panel);
             m_valLabel.Text = ""; // (max * 1000).Z.ToString("F3");

             ILPoint3Df mi = ILPoint3Df.Min(min, max);
             ILPoint3Df ma = ILPoint3Df.Max(min, max);
             m_valLabel.PositionMax = new ILPoint3Df(ma.X,mi.Y,ma.Z);
             m_valLabel.PositionMin = new ILPoint3Df(mi.X, ma.Y, ma.Z); ;

             m_topLabel = new ILShapeLabel(panel);
             m_topLabel.Color = Color.Blue;
             //m_topLabel.Font = new Font("Arial", 10, FontStyle.Bold);
             string tval = max.Z.ToString("F2");
             m_topLabel.Text =  String.Format("{0}",tval);
             m_topLabel.Anchor = new PointF(0.5f, 1); 

             m_topColor = topColor;

             #region setup quads
             m_quads = new ILLitQuad[6];

             // front
             ILLitQuad quad = new ILLitQuad(m_panel);
             quad.Vertices[0].Position = new ILPoint3Df(min.X, min.Y, min.Z);
             quad.Vertices[1].Position = new ILPoint3Df(min.X, min.Y, max.Z);
             quad.Vertices[2].Position = new ILPoint3Df(max.X, min.Y, max.Z);
             quad.Vertices[3].Position = new ILPoint3Df(max.X, min.Y, min.Z);
             m_quads[QuadIndices.front] = quad; 
             // right
             quad = new ILLitQuad(m_panel);
             quad.Vertices[0].Position = new ILPoint3Df(max.X, min.Y, min.Z);
             quad.Vertices[1].Position = new ILPoint3Df(max.X, min.Y, max.Z);
             quad.Vertices[2].Position = new ILPoint3Df(max.X, max.Y, max.Z);
             quad.Vertices[3].Position = new ILPoint3Df(max.X, max.Y, min.Z);
             m_quads[QuadIndices.right] = quad;
             // back
             quad = new ILLitQuad(m_panel);
             quad.Vertices[0].Position = new ILPoint3Df(max.X, max.Y, min.Z);
             quad.Vertices[1].Position = new ILPoint3Df(max.X, max.Y, max.Z);
             quad.Vertices[2].Position = new ILPoint3Df(min.X, max.Y, max.Z);
             quad.Vertices[3].Position = new ILPoint3Df(min.X, max.Y, min.Z);
             m_quads[QuadIndices.back] = quad;
             // left
             quad = new ILLitQuad(m_panel);
             quad.Vertices[0].Position = new ILPoint3Df(min.X, max.Y, min.Z);
             quad.Vertices[1].Position = new ILPoint3Df(min.X, max.Y, max.Z);
             quad.Vertices[2].Position = new ILPoint3Df(min.X, min.Y, max.Z);
             quad.Vertices[3].Position = new ILPoint3Df(min.X, min.Y, min.Z);
             m_quads[QuadIndices.left] = quad;
             // top
             quad = new ILLitQuad(m_panel); 
             quad.Vertices[0].Position = new ILPoint3Df(min.X, min.Y, max.Z);
             quad.Vertices[1].Position = new ILPoint3Df(max.X, min.Y, max.Z);
             quad.Vertices[2].Position = new ILPoint3Df(max.X, max.Y, max.Z);
             quad.Vertices[3].Position = new ILPoint3Df(min.X, max.Y, max.Z);
             m_quads[QuadIndices.top] = quad;
             // bottom
             quad = new ILLitQuad(m_panel);
             quad.Vertices[0].Position = new ILPoint3Df(min.X, min.Y, min.Z);
             quad.Vertices[1].Position = new ILPoint3Df(max.X, min.Y, min.Z);
             quad.Vertices[2].Position = new ILPoint3Df(max.X, max.Y, min.Z);
             quad.Vertices[3].Position = new ILPoint3Df(min.X, max.Y, min.Z);
             m_quads[QuadIndices.bottom] = quad;
             #endregion
             EventingSuspend();
             foreach (ILLitQuad s in m_quads) {
                 s.Label.Text = "";
                 s.Shading = ShadingStyles.Interpolate;
                 s.Opacity = m_opacity;
                 s.Border.Color = Color.Gray;
                 s.Border.Width = 1;
                 s.Border.Visible = true;
                 s.Border.Antialiasing = false; 
                 Add(s); 
             }
             EventingResume(); 
             m_fillColor = fillColor;
             updateColors();
         }
Esempio n. 37
0
 public static ILPoint3Df Max(ILPoint3Df val1, ILPoint3Df val2, ref bool changed) {
     ILPoint3Df ret = val1;  
     if (val2.X > val1.X) { 
         ret.X = val2.X; 
         changed = true; 
     }
     if (val2.Y > val1.Y) {
         ret.Y = val2.Y; 
         changed = true; 
     }
     if (val2.Z > val1.Z) {
         ret.Z = val2.Z; 
         changed = true; 
     }
     return ret; 
 }