示例#1
0
 /** NOTE: the connection from java to matlab */
 public RCvalue java2Matlab() throws EvalException {
   if (rc == null) {
     if (poly != null) {
       Value[] v = new Value[poly.degree()];
       for (int i = 0; i < v.length; i++) {
         Point pt = poly.point(i);
         assert pt.type() == CohoDouble.type
             : "The result type is not CohoDouble, it is " + pt.type();
         //					if(pt.type()!=CohoDouble.type){
         //					throw new RuntimeException("The result type is not CohoDouble, it is "+pt.type() );
         //					}
         v[i] =
             RCvalue.factory()
                 .create(
                     new Value[] {
                       DoubleValue.factory()
                           .create(new Double(((CohoDouble) pt.x()).doubleValue()), null),
                       DoubleValue.factory()
                           .create(new Double(((CohoDouble) pt.y()).doubleValue()), null)
                     },
                     false);
       }
       rc = (RCvalue) (RCvalue.factory().create(v, true));
     } else { // empty polygon
       rc = (RCvalue) (RCvalue.factory().create(new Value[0], true));
     }
   }
   return (rc);
 }
示例#2
0
 // value(lo) to value(hi-1)
 protected static Value grind(RCvalue args, Operation op, int lo, int hi) throws EvalException {
   switch (hi - lo) {
     case 0:
       return new PolygonValue(
           (RCvalue) (RCvalue.factory().create(new Value[] {}, true))); // empty
     case 1:
       return args.value(lo); // one
     case 2:
       Value result = op.op((PolygonValue) (args.value(lo)), (PolygonValue) (args.value(hi - 1)));
       return result; // two
     default:
       int mid = (lo + hi + 1) / 2; // split
       Value v0 = grind(args, op, lo, mid);
       Value v1 = grind(args, op, mid, hi);
       result = op.op((PolygonValue) (v0), (PolygonValue) (v1));
       return result;
   }
 }